You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Stebalien opened this issue
Jul 2, 2015
· 3 comments
Assignees
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)P-highHigh priorityT-langRelevant to the language team, which will review and decide on the PR/issue.
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 { }
^
The text was updated successfully, but these errors were encountered:
Stebalien
changed the title
In macros, rust allows expr to be followed by {
In macros, expr followed by { is buggy
Jul 2, 2015
huonw
added
I-nominated
T-lang
Relevant to the language team, which will review and decide on the PR/issue.
A-macros
Area: All kinds of macros (custom derive, macro_rules!, proc macros, ..)
labels
Jul 2, 2015
For this and other macro rules, it's unclear how much we can change here, but I think we should make an effort to fix these bugs sooner rather than later if we are going to do so!
(though i will note yet again that there may be motivation for adding a new syntactic class to macro rules, which I have been referring to tongue-in-cheek as $e:moelarry, but obviously we'd want to bikeshed a better name before we'd actually put it in for real...)
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)P-highHigh priorityT-langRelevant to the language team, which will review and decide on the PR/issue.
The following compiles:
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 parseident {}
as an invalid struct literal instantiation.The following works:
And the following doesn't:
Error:
The text was updated successfully, but these errors were encountered: