-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)P-highHigh priorityHigh priorityT-langRelevant to the language teamRelevant to the language team
Description
The following compiles:
macro_rules! test {
($e:expr {}) => {$e};
}
However, (1) this technically isn't allowed by the macro future proofing rules and (2) it doesn't work when $e
is an ident because rust tries to parse ident {}
as an invalid struct literal instantiation.
The following works:
test! {
1 + 1 { } // 1 + 1 can be anything other than an ident.
};
And the following doesn't:
test! {
ident { }
};
Error:
tmp.rs:10:15: 10:16 error: structure literal must either have at least one field or use functional structure update syntax
tmp.rs:10 ident { }
^
tmp.rs:10:17: 10:18 error: unexpected end of macro invocation
tmp.rs:10 ident { }
^
Metadata
Metadata
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)P-highHigh priorityHigh priorityT-langRelevant to the language teamRelevant to the language team