Closed
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 { }
^