-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Always parse macro invocations with () or [] as expressions #378
Conversation
I can shepherd this. Assigning to self. |
+1. I would like this change because it would make expression macros much more usable, especially those like the one in https://github.com/reem/rust-enforce. |
+1 I hope the semicolon rule for macros as statements (as opposed to as items) falls out naturally from the syntax for expressions and statements. |
Curious what @pcwalton and @nikomatsakis think. I don't have strong opinion but it seems to be more consistent with non-macro stmt/expr parsing. ISTR that This RFC is not using the template format for Rust RFCs. |
@brson The |
I am generally in favor of this. As @P1start noted, we had similar rules as part of the (now withdrawn) #208 RFC. One thing to clarify: these same restrictions would apply in all contexts, right? That is, also at the top-level:
If so, I am in favor because it improves the overall consistency of the language. |
Yes, these rules apply to item-position macros, too. The RFC states that it will ‘require all item-position macros to be invoked with either curly braces, |
@P1start sounds good to me, I missed that somehow. |
Accepted (squashed and merged as 4738e17 ) |
Parse macro invocations with parentheses or square brackets as expressions no matter the context, and require curly braces or a semicolon following the invocation to invoke a macro as a statement.
Resolves #364.
I think #208 also does this as a by-product of resolving another ambiguity with attributes.
Status: Active
RFC document: https://github.com/rust-lang/rfcs/blob/master/text/0378-expr-macros.md