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

Parsing an Expr fails with embedded macros in expression position #526

Closed
dhardy opened this issue Nov 2, 2018 · 2 comments
Closed

Parsing an Expr fails with embedded macros in expression position #526

dhardy opened this issue Nov 2, 2018 · 2 comments

Comments

@dhardy
Copy link
Contributor

dhardy commented Nov 2, 2018

As in the title, let expr: Expr = input.parse()?; fails on content containing a macro.

I'm not actually sure whether this should be supported, though it works for declarative macros.

Related: rust-lang/rust#54727 (procedural macros can't currently be used in expression position; though declarative macros can be).

@dtolnay
Copy link
Owner

dtolnay commented Nov 2, 2018

You may need to enable the "full" feature if you are parsing expressions: https://github.com/dtolnay/syn#optional-features. By default we only parse the basic subset of expressions that typically appear as array lengths.

For procedural macros in expression position check out https://github.com/dtolnay/proc-macro-hack.

@dhardy
Copy link
Contributor Author

dhardy commented Nov 3, 2018

Oh, was wondering whether I should try that, but didn't think a feature combination would allow only limited parsing. Will do.

Awesome! Thanks for all the hacks around macros. I'm currently using nightly-only and only at the proof-of-concept stage, so just using the nightly feature flag.

@dhardy dhardy closed this as completed Nov 3, 2018
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

No branches or pull requests

2 participants