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

Comments

Projects
None yet
8 participants
@SimonSapin
Copy link
Contributor

SimonSapin commented Nov 10, 2014

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 label Nov 10, 2014

@SimonSapin

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Nov 10, 2014

@eddyb on IRC:

it should be easy

@dwrensha

This comment has been minimized.

Copy link
Contributor

dwrensha commented Nov 10, 2014

This would be quite convenient.

@eddyb

This comment has been minimized.

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

This comment has been minimized.

Copy link
Contributor Author

SimonSapin commented Jan 14, 2015

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

@huonw

This comment has been minimized.

Copy link
Member

huonw commented Nov 18, 2015

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

Should be fine, yes.

@SirVer

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Jun 25, 2017

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

This comment has been minimized.

Copy link
Contributor

pierzchalski commented Aug 14, 2017

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

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Aug 15, 2017

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

@mjbshaw

This comment has been minimized.

Copy link
Contributor

mjbshaw commented Jan 4, 2018

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

@pierzchalski

This comment has been minimized.

Copy link
Contributor

pierzchalski commented Jan 5, 2018

@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
You can’t perform that action at this time.