bugfix(parser): Make macro a valid recovery terminal and tree token. - #10149
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryLow Risk Overview Error recovery at module level now treats Regression tests cover Reviewed by Cursor Bugbot for commit cb52b24. Bugbot is set up for automated code reviews on this repo. Configure here. |
TomerStarkware
left a comment
There was a problem hiding this comment.
@TomerStarkware reviewed 4 files and all commit messages, and made 1 comment.
Reviewable status:complete! all files reviewed, all discussions resolved (waiting on eytan-starkware).

Summary
Fixes an ICE (Internal Compiler Error) that occurred when the
macrokeyword was used as a token inside an inline macro call (e.g.,foo!(macro)). TheTerminalMacrosyntax kind was missing from the parser's token-tree leaf handling, causing a panic. Additionally,TerminalMacrowas not included in the error recovery set of module-level keywords, meaning amacrodeclaration following a malformed item would not correctly stop error recovery.Type of change
Please check one:
Why is this change needed?
TerminalMacrowas absent from the parser's token-tree leaf dispatch inparser.rs, so encounteringmacroas a leaf token inside an inline macro invocation caused an ICE. It was also missing from themodule_item_kw!recovery macro inrecovery.rs, so error recovery would not stop at amacrodeclaration boundary when recovering from a prior parse error.What was the behavior or documentation before?
macroas an argument to an inline macro call (e.g.,foo!(macro)) caused an internal compiler error (panic).macrodeclaration following a malformed item (e.g.,const Xwith no type or value) would not act as a recovery boundary, potentially producing confusing cascading diagnostics.What is the behavior or documentation after?
foo!(macro)is parsed correctly without panicking;macrois treated as aTokenTreeLeafwith kindTokenMacro.macrokeyword at module level, consistent with other module-item keywords likestruct,fn,impl, etc.Related issue or discussion (if any)
Regression fix for #10144.
Additional context
Two new test cases are added: one verifying the inline macro regression no longer ICEs, and one verifying that error recovery halts correctly at a following
macrodeclaration.