Skip to content

Paths in cfg_attr should be honored #3

@TedDriggs

Description

@TedDriggs

Consider the following example from dtolnay/request-for-implementation#6

r#"
#[cfg(feature = "m1")]
mod m1;

#[cfg_attr(feature = "m2", path = "m2.rs")]
#[cfg_attr(not(feature = "m2"), path = "empty.rs")]
mod placeholder;

According to that ticket, this should expand to two declarations of mod placeholder, with the cfg_attr being converted to a normal cfg attribute.

I'm not sure this is worth the complexity it creates. Consider the following case:

#[cfg_attr(feature = "foo", path = "m2")]
#[cfg_attr(not(feature = "foo"), path = "m3")]
mod outer {
    #[cfg_attr(feature = "foo", path = "baz.rs")]
    #[cfg_attr(not(feature = "foo"), path = "bar.rs")]
    mod placeholder;
}

We'd need to emit outer twice, with placeholder twice inside.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions