Skip to content

Macro-expanded unconfigured items are gated feature checked #32840

Closed
@jseyfried

Description

@jseyfried

Macro-expanded unconfigured items are gated feature checked, but ordinary unconfigured items are not. For example, the following should compile, ...

#![cfg_attr(attr, feature(rustc_attrs))]

macro_rules! mac {
    {} => {
        #[cfg(attr)]
        mod m {
            #[rustc_error] // ... but if not(attr), this complains about the lack of the rustc_attrs feature
            fn f() {}
        }
    }
}

mac! {}

If we manually expand mac! {}, it always compiles:

#![cfg_attr(attr, feature(rustc_attrs))]

#[cfg(attr)]
mod m {
    #[rustc_error]
    fn f() {}
}

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