From b3d57aff7a82016d56ef8ec11834284b4f4e59f3 Mon Sep 17 00:00:00 2001 From: Geoff Romer Date: Fri, 13 Feb 2026 14:44:23 -0800 Subject: [PATCH] Diagnose if a NodeIdOneOf argument isn't a typed node. (#6738) --- toolchain/parse/node_ids.h | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/toolchain/parse/node_ids.h b/toolchain/parse/node_ids.h index 1347a20ea86f..58a437757cbb 100644 --- a/toolchain/parse/node_ids.h +++ b/toolchain/parse/node_ids.h @@ -113,9 +113,20 @@ using AnyRequirementId = NodeIdInCategory; using AnyNonExprNameId = NodeIdInCategory; using AnyPackageNameId = NodeIdInCategory; +namespace Internal { +template +concept IsNodeKind = std::same_as, NodeKind> || + std::same_as, NodeKind::Definition>; + +template +concept IsTypedNode = requires { + { T::Kind } -> IsNodeKind; +}; +} // namespace Internal + // NodeId with kind that matches one of the `T::Kind`s. template - requires(sizeof...(T) >= 2) + requires(sizeof...(T) >= 2 && (Internal::IsTypedNode && ...)) struct NodeIdOneOf : public NodeId { private: // True if `OtherT` is one of `T`.