Change NodeIdOneOf and similar to use "requires" and explicit UnsafeMake (#5084)

This doesn't change functionality, but I was seeing better diagnostics
in VS Code.

This also changes the NodeId constructors for related types (also
NodeCategory and NodeIdForKind) to use UnsafeMake for construction. That
originated from avoiding ambiguity coming from `requires`, but the
constructor mode is also one we should typically avoid (e.g., preferring
`Parse::Tree::As`).
This commit is contained in:
Jon Ross-Perkins
2025-03-12 00:33:54 +00:00
committed by GitHub
parent ebaf62efb9
commit e6872f9499
8 changed files with 66 additions and 38 deletions
+3 -3
View File
@@ -449,8 +449,8 @@ auto Context::AddFunctionDefinitionStart(Lex::TokenIndex token, bool has_error)
-> void {
if (ParsingInDeferredDefinitionScope(*this)) {
deferred_definition_stack_.push_back(tree_->deferred_definitions_.Add(
{.start_id =
FunctionDefinitionStartId(NodeId(tree_->node_impls_.size()))}));
{.start_id = FunctionDefinitionStartId::UnsafeMake(
NodeId(tree_->node_impls_.size()))}));
}
AddNode(NodeKind::FunctionDefinitionStart, token, has_error);
@@ -462,7 +462,7 @@ auto Context::AddFunctionDefinition(Lex::TokenIndex token, bool has_error)
auto definition_index = deferred_definition_stack_.pop_back_val();
auto& definition = tree_->deferred_definitions_.Get(definition_index);
definition.definition_id =
FunctionDefinitionId(NodeId(tree_->node_impls_.size()));
FunctionDefinitionId::UnsafeMake(NodeId(tree_->node_impls_.size()));
definition.next_definition_index =
DeferredDefinitionIndex(tree_->deferred_definitions().size());
}