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
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.

Show comment
Hide comment
@SimonSapin

SimonSapin Nov 10, 2014

Contributor

@eddyb on IRC:

it should be easy

Contributor

SimonSapin commented Nov 10, 2014

@eddyb on IRC:

it should be easy

@dwrensha

This comment has been minimized.

Show comment
Hide comment
@dwrensha

dwrensha Nov 10, 2014

Contributor

This would be quite convenient.

Contributor

dwrensha commented Nov 10, 2014

This would be quite convenient.

@eddyb

This comment has been minimized.

Show comment
Hide comment
@eddyb

eddyb Nov 10, 2014

Member

@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.

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.

Show comment
Hide comment
@SimonSapin

SimonSapin Jan 14, 2015

Contributor

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

Contributor

SimonSapin commented Jan 14, 2015

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

@huonw

This comment has been minimized.

Show comment
Hide comment
@huonw

huonw Nov 18, 2015

Member

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

Should be fine, yes.

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.

Show comment
Hide comment
@SirVer

SirVer 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.

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.

Show comment
Hide comment
@Mark-Simulacrum

Mark-Simulacrum Jun 25, 2017

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.

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.

Show comment
Hide comment
@pierzchalski

pierzchalski Aug 14, 2017

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

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.

Show comment
Hide comment
@Mark-Simulacrum

Mark-Simulacrum Aug 15, 2017

Member

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

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.

Show comment
Hide comment
@mjbshaw

mjbshaw Jan 4, 2018

Contributor

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

Contributor

mjbshaw commented Jan 4, 2018

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

@pierzchalski

This comment has been minimized.

Show comment
Hide comment
@pierzchalski

pierzchalski Jan 5, 2018

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.

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