Refactor diagnostics out of parser_context.h (#2834)

This is addressing an issue left behind by the context switch, removing a few diagnostics that had been in the header rather than figuring out proper homes. I'm splitting one for semis a little further, sharing one, and then the other two are actually able to be moved into more specific homes as-is (one is only used in one place, clearly an oversight that it wasn't there already).
This commit is contained in:
Jon Ross-Perkins
2023-05-18 12:45:08 -07:00
committed by GitHub
parent 75f1ac3a08
commit 8ad08e34e2
17 changed files with 43 additions and 40 deletions
@@ -13,6 +13,9 @@ static auto ParserHandleDeclarationNameAndParams(ParserContext& context,
if (!context.ConsumeAndAddLeafNodeIf(TokenKind::Identifier,
ParseNodeKind::DeclaredName)) {
CARBON_DIAGNOSTIC(ExpectedDeclarationName, Error,
"`{0}` introducer should be followed by a name.",
TokenKind);
context.emitter().Emit(*context.position(), ExpectedDeclarationName,
context.tokens().GetKind(state.token));
context.ReturnErrorOnState();