fix(semantic): match a pattern subtree only against a call subtree with the same delimiters - #10303
Conversation
a53a9fc to
e2eb1e2
Compare
08026fe to
b654579
Compare
PR SummaryMedium Risk Overview In Tests cover multi-rule fallback, nested inner subtrees, non-first subtree elements, empty Reviewed by Cursor Bugbot for commit e6ca70b. Bugbot is set up for automated code reviews on this repo. Configure here. |
b654579 to
e8f1e18
Compare
09a334a to
9719407
Compare
e8f1e18 to
7a54e5b
Compare
7a54e5b to
5596948
Compare
9719407 to
1807ca6
Compare
…th the same delimiters
The `MacroElement::Subtree` matching arm never compared the delimiter kind of the pattern subtree
against the input subtree, so a rule `([$x:ident])` matched the call `m!({a})`. Compare the
delimiter kinds, treating a mismatch as a rule-match failure so a later rule may still match, as
rustc does.
Also resolves the adjacent `TODO(Dean)` about bracket terminal consistency: a pattern subtree
cannot have inconsistent delimiters in the AST, and a pattern missing a closing delimiter is
reported by the parser and its rule is already dropped - so no declaration time check is needed.
1807ca6 to
e6ca70b
Compare

The
MacroElement::Subtreematching arm never compared the delimiter kind of the pattern subtreeagainst the input subtree, so a rule
([$x:ident])matched the callm!({a}). Compare thedelimiter kinds, treating a mismatch as a rule-match failure so a later rule may still match, as
rustc does.
Also resolves the adjacent
TODO(Dean)about bracket terminal consistency: a pattern subtreecannot have inconsistent delimiters in the AST, and a pattern missing a closing delimiter is
reported by the parser and its rule is already dropped - so no declaration time check is needed.