Skip to content

Should include! be recommended? #824

Closed
@SimonSapin

Description

@SimonSapin

Cargo recommends the include! macro to use generated code.

include!(concat!(env!("OUT_DIR"), "/hello.rs"))

However, it doesn’t seem to be documented, and its source comments say

This is generally a bad idea because it's going to behave unhygienically.

So, is include! the way forward, or should we find some other mechanism? Maybe make something like this work? (It currently gives error: unexpected token: concat``)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions