mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-10-05 15:51:07 +01:00
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:
@@ -155,7 +155,7 @@ struct Extractable<NodeIdForKind<Kind>> {
|
||||
static auto Extract(NodeExtractor& extractor)
|
||||
-> std::optional<NodeIdForKind<Kind>> {
|
||||
if (extractor.MatchesNodeIdForKind(Kind)) {
|
||||
return NodeIdForKind<Kind>(extractor.ExtractNode());
|
||||
return NodeIdForKind<Kind>::UnsafeMake(extractor.ExtractNode());
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -182,7 +182,7 @@ struct Extractable<NodeIdInCategory<Category>> {
|
||||
static auto Extract(NodeExtractor& extractor)
|
||||
-> std::optional<NodeIdInCategory<Category>> {
|
||||
if (extractor.MatchesNodeIdInCategory(Category)) {
|
||||
return NodeIdInCategory<Category>(extractor.ExtractNode());
|
||||
return NodeIdInCategory<Category>::UnsafeMake(extractor.ExtractNode());
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
@@ -227,7 +227,7 @@ struct Extractable<NodeIdOneOf<T...>> {
|
||||
static auto Extract(NodeExtractor& extractor)
|
||||
-> std::optional<NodeIdOneOf<T...>> {
|
||||
if (extractor.MatchesNodeIdOneOf({T::Kind...})) {
|
||||
return NodeIdOneOf<T...>(extractor.ExtractNode());
|
||||
return NodeIdOneOf<T...>::UnsafeMake(extractor.ExtractNode());
|
||||
} else {
|
||||
return std::nullopt;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user