Skip to content

Expand macros in attributes #18849

Closed
Closed
@SimonSapin

Description

@SimonSapin

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-syntaxextArea: Syntax extensionsT-langRelevant to the language team

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions