Skip to content

Functions/modules using unstable *syntax* (e.g., impl Trait) can't be CFGed out on stable #36478

Description

@Stebalien

This fails on stable because rust still parses the unstable module:

#[cfg(feature = "unstable")]
mod unstable {
    fn foo() -> impl Foo {}
}

It's possible to work around this by conditionally defining a macro and then having the macro define the module but that's a bit messy:

#[cfg(feature = "unstable")]
macro_rules! decl_unstable {
    () =>  {
        mod unstable {
            fn foo() -> impl Foo {}
        }
    }
}

#[cfg(not(feature = "unstable"))]
macro_rules! decl_unstable {
    () =>  {}
}

decl_unstable!();

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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