-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
reject macros with empty repetitions #36721
Conversation
r? @nrc (rust_highfive has picked a reviewer for you, use r? to override) |
@@ -358,6 +358,10 @@ pub fn compile<'cx>(cx: &'cx mut ExtCtxt, | |||
valid &= check_rhs(cx, rhs); | |||
} | |||
|
|||
for lhs in &lhses { | |||
valid &= check_lhs_no_empty_seq(cx, &[lhs.clone()]) | |||
} |
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.
could use lhses.iter().all()
instead of the for
loop.
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.
The for
loop was mainly used to use the same style as the loop of the rhses
directly above.
Also .iter().all()
would abort early, I think, which means that not all lhses
would be checked, ie. not all errors we could report would be reported.
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.
ok, good point on not reporting all errors. Could you add a comment to explain that please?
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.
Done.
r=me with the |
2bbef65
to
d06a9ca
Compare
@bors: r+ |
📌 Commit d06a9ca has been approved by |
☔ The latest upstream changes (presumably #36616) made this pull request unmergeable. Please resolve the merge conflicts. |
d06a9ca
to
51ea050
Compare
Rebased. |
@bors: r+ |
📌 Commit 51ea050 has been approved by |
reject macros with empty repetitions Fixes rust-lang#5067 by checking the lhs of `macro_rules!` for repetitions which could match an empty token tree.
reject macros with empty repetitions Fixes rust-lang#5067 by checking the lhs of `macro_rules!` for repetitions which could match an empty token tree.
Fixes #5067 by checking the lhs of
macro_rules!
for repetitions which could match an empty token tree.