Skip to content

Don't use unstable syntax without some sort of parsing guard #156

Closed
@leoyvens

Description

@leoyvens

We had a situation in rust-lang/rust#46480 where we had trouble removing support for an unstable syntax in the parser because a popular crate (crossbeam) used the syntax behind a simple feature gate:

#[cfg(nightly)]
impl UnstableSyntax for .. {}

Because we only process cfgs after parsing, the cfg doesn't help at all in this case, causing de facto stability of the parser's support for unstable syntax. This situation is likely to repeat itself, we must teach lib authors to only use unstable syntax inside a mod that is cfged at it's declaration, such as:

#[cfg(nightly)]
mod contains_unstable_syntax;

or behind a macro:

#[cfg(nightly)]
macro_rules unstable_syntax! { /* expand to unstable syntax */ }

#[cfg(not(nightly))]
macro_rules unstable_syntax! { /* expand to nothing */ }

cc @petrochenkov

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