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
pnkfelix opened this issue
Nov 12, 2015
· 2 comments
Labels
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)T-langRelevant to the language team, which will review and decide on the PR/issue.
% rustc /tmp/seq.rs
/tmp/seq.rs:10:12:10:14 error: mismatched types:expected `()`,
found `&'static str`
(expected (),
found &-ptr)[E0308]
/tmp/seq.rs:10{seq!(""4);}
^~
/tmp/seq.rs:10:7:10:20 note:in this expansion of seq! (defined in /tmp/seq.rs)
/tmp/seq.rs:10:12:10:14 help: run `rustc --explain E0308` to see a detailed explanation
error: aborting due to previous error
%
but according to rustc -Z unstable-options --pretty expanded, there is no difference between the second seq! and the expression that precedes it:
This is almost certainly related to the "statements that do not have semicolons must have unit type". I imagine it's related to the parser's behavior when it encounters an "expr token". The pretty printer output is probably somewhat misleading.
The example now doesn't compile with a different error, which seems correct, since () "" isn't valid Rust. This appears to be because the macro no longer inserts semicolons after expressions automatically, if the macro is edited to insert them (($($e:expr)*) => ($($e;)*); then the code does, indeed, compile.
New error:
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `""`
--> src/lib.rs:2:25
|
2 | ($($e:expr)*) => ($($e)*);
| ^^ expected one of `.`, `;`, `?`, `}`, or an operator here
error: expected one of `.`, `;`, `?`, `}`, or an operator, found `4`
--> src/lib.rs:2:25
|
2 | ($($e:expr)*) => ($($e)*);
| ^^ expected one of `.`, `;`, `?`, `}`, or an operator here
error: aborting due to 2 previous errors
A-macrosArea: All kinds of macros (custom derive, macro_rules!, proc macros, ..)T-langRelevant to the language team, which will review and decide on the PR/issue.
(spawned off of #25658)
This may not necessarily be a macro expansion issue, but that seems like the most likely candidate.
The following code:
yields the following compilation error:
but according to
rustc -Z unstable-options --pretty expanded
, there is no difference between the secondseq!
and the expression that precedes it:(My current suspicion is that the
--pretty expanded
is not showing us the closest match to the actual AST being produced by expansion.)The text was updated successfully, but these errors were encountered: