mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-01 15:35:53 +01:00
Change TokenKind's Print overload to a format_provider. (#2534)
Fundamentally this `.Print()` is wrong for debug output at present because `.fixed_spelling()` can be empty. It's also inconsistent with other enums to use it. We frequently print tokens for debugging, and it's easy to forget to specify `.name()` there. Diagnostics use formatv, so we can provide a format_provider and address it in one spot that way. It also makes it harder to just forget to do the right thing.
This commit is contained in:
@@ -350,7 +350,7 @@ auto SemanticsParseTreeHandler::HandleInfixOperator(ParseTree::Node parse_node)
|
||||
parse_node, result_type, lhs_id, rhs_id));
|
||||
break;
|
||||
default:
|
||||
CARBON_FATAL() << "Unrecognized token kind: " << token_kind.name();
|
||||
CARBON_FATAL() << "Unrecognized token kind: " << token_kind;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,7 +393,7 @@ auto SemanticsParseTreeHandler::HandleLiteral(ParseTree::Node parse_node)
|
||||
break;
|
||||
}
|
||||
default:
|
||||
CARBON_FATAL() << "Unhandled kind: " << token_kind.name();
|
||||
CARBON_FATAL() << "Unhandled kind: " << token_kind;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user