-
Notifications
You must be signed in to change notification settings - Fork 13.3k
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
Macros attempting to expand to multiple items silently only expand to the first one #8012
Comments
Thanks to |
Perhaps this is really just another plaintive cry for someone to tackle #4375. |
Smaller testcase: rusti> macro_rules! t( () => { println("hi"); println("oops"); }) t!()
hi
() |
I don't understand how this is different than #4375. If not justification for the distinction is given, can we mark this as a duplicate? |
This source of this problem probably isn't specific to items. I'm worried |
Yeah,
|
That is, only a single expression or item gets parsed, so if there are any extra tokens (e.g. the start of another item/expression) the user should be told, rather than silently dropping them. An example: macro_rules! foo { () => { println("hi"); println("bye); } } would expand to just `println("hi")`, which is almost certainly not what the programmer wanted. Fixes #8012.
Users who want a macro that expands to a collection items are required to wrap the RHS in
{}
in order to get them to expand to a whole block. However, if they fail to do so, they unexpectedly just get the first item of the block, rather than an error message....expands to...
The text was updated successfully, but these errors were encountered: