Skip to content
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

Syntax extensions (and macros) that start a line want to be a whole statement #364

Closed
rust-highfive opened this issue Oct 7, 2014 · 2 comments

Comments

@rust-highfive
Copy link

Issue by paulstansifer
Thursday Apr 18, 2013 at 19:37 GMT

For earlier discussion, see rust-lang/rust#5941

This issue was labelled with: A-parser, A-syntaxext, P-high in the Rust repository


{ stringify!(bees).to_owned() }
 foo.rs:5:27: 5:28 error: unexpected token: `.`
 foo.rs:5          { stringify!(bees).to_owned() }
                                     ^

However, if you wrap the macro invocation in parens...

 { (stringify!(bees)).to_owned() }

...it works.

The tricky thing about this problem is that, when the parser sees stringify!, it doesn't know whether it'll be a statement macro or an expression macro; currently, it commits to the former, which breaks if the invocation has to be an expression.

@Stebalien
Copy link
Contributor

Triage: fixed (also, probably in the wrong repo...).

@Stebalien
Copy link
Contributor

@alexcrichton (at random, sorry)

wycats added a commit to wycats/rust-rfcs that referenced this issue Mar 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants