Uh oh!
There was an error while loading. Please reload this page.
Accept a LHS formed of a single sequence TT in macro_rules!. - #33689
Accept a LHS formed of a single sequence TT in macro_rules!.#33689LeoTestard wants to merge 1 commit into
macro_rules!.#33689Conversation
rust-highfive
commented
May 17, 2016
r? @sfackler (rust_highfive has picked a reviewer for you, use r? to override) |
sfackler
commented
May 17, 2016
I always thought the lhs of a macro had to be wrapped in |
LeoTestard
commented
May 17, 2016
That's not what |
This was already accepted when checking that a macro definition was well-formed but not handled during expansion.
19f07a4 to
3c8ba2dCompareLeoTestard
commented
May 17, 2016
Made it a bit clearer (and closer to the old code and to |
nrc
commented
May 18, 2016
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. |
LeoTestard
commented
May 18, 2016
@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... |
sanxiyn
commented
May 18, 2016
Travis failed |
LeoTestard
commented
May 18, 2016
Yep, I saw. Waiting for the lang team decision to fix it. |
nikomatsakis
commented
May 20, 2016
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. |
LeoTestard
commented
May 20, 2016
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. |
LeoTestard
commented
May 23, 2016
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.