-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Accept a LHS formed of a single sequence TT in macro_rules!
.
#33689
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
Conversation
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
I always thought the lhs of a macro had to be wrapped in |
That's not what
|
This was already accepted when checking that a macro definition was well-formed but not handled during expansion.
19f07a4
to
3c8ba2d
Compare
Made it a bit clearer (and closer to the old code and to |
Nominating for lang team discussion. This does effectively make the macro syntax more permissive. I am somewhat against this idea since I would like to link the kind of bracket in the lhs with the bracket used in the macro use (in macros 2.0) and this change drifts away from that, rather than closer to it. Is there an advantage to allowing this syntax? It doesn't read any better to my eyes, although I guess it is closer to match arms and if statements where we don't require delimiters. I think I'd be happier if we could only do this, rather than making them optional. |
@nrc I'm not sure what you mean by just don't requiring delimiters. Because it would be unambiguous only when the matcher consists of a single TT. Otherwise it's not possible to match the I guess we can also just forbid that and just fix the macro rules compilation to report it when a macro is declared rather than on expansion... |
Travis failed |
Yep, I saw. Waiting for the lang team decision to fix it. |
Leaving this nominated since @nrc wasn't present at the last @rust-lang/lang meeting, and we wanted to get his take before we decided on anything. |
Talked about it with @pnkfelix today. We agreed that the best solution was probably to close this PR and to instead fix the macro definition checking phase to reject such macros. |
Closing since this is not what we want. I'll open another PR. |
Reject a LHS formed of a single sequence TT during `macro_rules!` checking. This was already rejected during expansion. Encountering malformed LHS or RHS during expansion is now considered a bug. Follow up to #33689. r? @pnkfelix Note: this can break code that defines such macros but does not use them.
…kfelix Reject a LHS formed of a single sequence TT during `macro_rules!` checking. This was already rejected during expansion. Encountering malformed LHS or RHS during expansion is now considered a bug. Follow up to rust-lang#33689. r? @pnkfelix Note: this can break code that defines such macros but does not use them.
This is already accepted when checking that a macro definition is well-formed but not handled during expansion.
There is no reason to reject that since a sequence TT is a single TT.
This does not apply to macro RHSes, though, which must still be formed of a delimited TT. It would be cool to have it too, for consistency, but the purpose of this PR was to fix the inconsistency between macro definition checking and macro expansion, which was obviously a bug. Since a single sequence TT RHS is rejected in both places, I think it would be better to do a separate PR.