-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Fix ICE on invalid variable declarations in macro calls #105141
Fix ICE on invalid variable declarations in macro calls #105141
Conversation
r? @TaKO8Ki (rustbot has picked a reviewer for you, use r? to override) |
@@ -73,13 +73,13 @@ impl<'a> Parser<'a> { | |||
Ok(Some(if self.token.is_keyword(kw::Let) { | |||
self.parse_local_mk(lo, attrs, capture_semi, force_collect)? | |||
} else if self.is_kw_followed_by_ident(kw::Mut) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you use a may_recover
check in all of these failure branches?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I mean the var
and mut
, etc. branches
@@ -117,7 +117,7 @@ macro_rules! maybe_recover_from_interpolated_ty_qpath { | |||
}; | |||
} | |||
|
|||
#[derive(Clone, Copy)] | |||
#[derive(Clone, Copy, Debug)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this needed for something? Otherwise, can you remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, I was using this for debugging, so thought this might be useful. Anyway, I'll remove it. Thanks!
Please use |
Fix ICE on parsing an invalid variable declaration as a statement like: ``` macro_rules! m { ($s:stmt) => {} } m! { var x } ```
Previously, the `recover_local_after_let` function was called from the body of the `recover_stmt_local` function. Unifying these two functions make it more simple and more readable.
3a78430
to
e481258
Compare
@compiler-errors Thank you for the review! Fixed. |
@bors r+ rollup |
…iaskrgr Rollup of 6 pull requests Successful merges: - rust-lang#101975 (Suggest to use . instead of :: when accessing a method of an object) - rust-lang#105141 (Fix ICE on invalid variable declarations in macro calls) - rust-lang#105224 (Properly substitute inherent associated types.) - rust-lang#105236 (Add regression test for rust-lang#47814) - rust-lang#105247 (Use parent function WfCheckingContext to check RPITIT.) - rust-lang#105253 (Update a couple of rustbuild deps) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This fixes ICE that happens with invalid variable declarations in macro calls like:
Found this is because of not collecting tokens on recovery, so I changed to force collect them.
Fixes #103529.