-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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_rules!
thinks use
is an ident
. It isn't.
#40569
Comments
|
From that issue:
The second case given in this issue is a very concrete benefit from that restriction. 😄 |
It looks like repeaters can pretty easily confuse macro_rules! my_struct {
($(#[$meta:meta])* $ident:ident) => {
$(#[$meta])* struct $ident;
}
}
my_struct!(#[derive(Debug)] Foo); causes it to complain that it doesn't know if |
The repetition thing is because |
One specific common macro that this would break is Serde's |
Fixes rust-lang#24189. Fixes rust-lang#26444. Fixes rust-lang#27832. Fixes rust-lang#34030. Fixes rust-lang#35650. Fixes rust-lang#39964. Fixes the 4th comment in rust-lang#40569. Fixes the issue blocking rust-lang#40984.
…seyfried Only match a fragment specifier the if it starts with certain tokens. When trying to match a fragment specifier, we first predict whether the current token can be matched at all. If it cannot be matched, don't bother to push the Earley item to `bb_eis`. This can fix a lot of issues which otherwise requires full backtracking (#42838). In this PR the prediction treatment is not done for `:item`, `:stmt` and `:tt`, but it could be expanded in the future. Fixes #24189. Fixes #26444. Fixes #27832. Fixes #34030. Fixes #35650. Fixes #39964. Fixes the 4th comment in #40569. Fixes the issue blocking #40984.
Closing as works-as-expected and cannot-be-changed. |
This code should fail to compile, giving the same error message as
fn use()
would give, but it compiles successfully.This code should compile successfully. However, it fails complaining that it can't decide whether
use
is an ident or not (hint: it isn't). It also shouldn't be trying to matchuse
as an ident because of the semicolon, but that's a broader/deeper issue withmacro_rules!
The text was updated successfully, but these errors were encountered: