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

Expand macros in attributes #18849

Closed
SimonSapin opened this issue Nov 10, 2014 · 11 comments
Closed

Expand macros in attributes #18849

SimonSapin opened this issue Nov 10, 2014 · 11 comments
Labels
A-syntaxext Area: Syntax extensions T-lang Relevant to the language team, which will review and decide on the PR/issue.

Comments

@SimonSapin
Copy link
Contributor

Something like this would be nice for code generation in Cargo. (See rust-lang/cargo#824.)

#[path = concat!(env!("OUT_DIR"), "/hello.rs")]
mod foo;

But it currently doesn’t parse:

a.rs:1:10: 1:16 error: unexpected token: `concat`
a.rs:1 #[path = concat!(env!("OUT_DIR"), "/hello.rs")]
                ^~~~~~

Can we make this work? I have a hack in #18810 (comment) to work around it, but it’s ugly.

CC @alexcrichton @eddyb

@huonw huonw added the A-syntaxext Area: Syntax extensions label Nov 10, 2014
@SimonSapin
Copy link
Contributor Author

@eddyb on IRC:

it should be easy

@dwrensha
Copy link
Contributor

This would be quite convenient.

@eddyb
Copy link
Member

eddyb commented Nov 10, 2014

@SimonSapin you quoted me out of context, you get to write the RFC for it.
Though I have to wonder how mod foo; will work, right now the parser expands it right as it parses the initial AST.

@SimonSapin
Copy link
Contributor Author

Is it possible to do this backward-compatibly after 1.0?

@huonw huonw added the T-lang Relevant to the language team, which will review and decide on the PR/issue. label Nov 18, 2015
@huonw
Copy link
Member

huonw commented Nov 18, 2015

Is it possible to do this backward-compatibly after 1.0?

Should be fine, yes.

@SirVer
Copy link

SirVer commented Dec 8, 2016

Future searchers: I stumbled on this issue as I created a generated module in build.rs and #18810 contained a work around that helped me.

@Mark-Simulacrum
Copy link
Member

Closing. If someone wants to pursue this, please follow the RFC process here https://github.com/rust-lang/rfcs#before-creating-an-rfc; the change is major enough to warrant this.

@pierzchalski
Copy link
Contributor

Is anyone working on this, or is there an RFC in the pipeline? If not, I'm willing to start work on one.
CC @Mark-Simulacrum

@Mark-Simulacrum
Copy link
Member

To my knowledge no one is working on this, but asking on internals.rust-lang.org is likely a good start.

@mjbshaw
Copy link
Contributor

mjbshaw commented Jan 4, 2018

@pierzchalski Have you gotten a chance to start an RFC for this?

@pierzchalski
Copy link
Contributor

@mjbshaw there didn't seem to be a lot of interest on the pre-RFC I wrote, but that might have been because I wrote it in the middle of the impl period. I might write up the RFC itself some time this/next week and see how well it goes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-syntaxext Area: Syntax extensions T-lang Relevant to the language team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants