-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
macro parses let
keyword as pattern and fails + masked regression
#109045
Comments
Yeah, feel free to gate the recovery behavior behind |
That still leaves the other error. Is that error intended behavior? I think not, although it's been present since (at least) 1.0.0. |
You could consider adding Btw, I don't think your The expression parser is quite good at that though, the pattern and item parsers not so much it seems. I think the |
Yeah we could do that but it would become unsustainable. Ultimately, when not in a macro context, not suggesting I'm honestly not particularly inclined to fix this because it has existed since 1.0.0. I agree that to fix all these little issues with macros will require significant changes and I don't think it's worth it right now. However, I will lump the @rustbot P-low |
I tried this code:
I expected the code to compile and the macro to expand as follows:
Instead, compilation failed:
Meta
rustc --version --verbose
:Occurs on latest stable and nightly.
Additional context
I believe there are two issues here:
let
as an identifier and then fails because it is not a valid identifier;Parser::can_be_ident_pat
(seecompiler/rustc_parse/parser/pat.rs:811
) returns true on keywords and then the caller (compiler/rustc_parse/parser/pat.rs:398
) attempts to parse an ident pattern and promptly fails because it sees a keyword.compiler/rustc_parse/parser/pat.rs:345
) which eagerly consumes tokens without being behind aParser::may_recover
gate (this is similar to Breaking change in macro_rules ty fragment parsing in version 1.68 #107796, that regression I caused, right? cc @compiler-errors):If this is correct, I'd like to PR it please :).
The text was updated successfully, but these errors were encountered: