Skip to content

allow_internal_unstable can be used to bypass incomplete_features warning #128175

Open
@RalfJung

Description

@RalfJung

The following example uses the incomplete dyn_star feature, which should trigger a warning, but the warning does not show:

#![feature(allow_internal_unstable)]
#![feature(decl_macro, staged_api, example)]
#![allow(internal_features)]
#![unstable(feature = "example", issue = "none")]

#[allow_internal_unstable(dyn_star)]
macro generate {
    ($name:ident) => {
        fn $name() {
            use std::fmt::Debug;
        
            let _x: dyn* Debug;
        }
    }
}

generate!(example);

fn main() {
    example();
}

This is a problem since we want to use the lint to enforce that e.g. std does not depend on incomplete features, and this issue could lead to us accidentally depending on incomplete features anyway!

We probably have to make the incomplete_features lint scan not just the module-level #![feature] declarations, but also the allow_internal_unstable (and rustc_allow_const_fn_unstable).

Or, alternatively, maybe allow_internal_unstable should only allow features that are enabled in the crate where the macro is declared? It seems a bit odd to say "ah yes this macro can internally use feature X anywhere it is expanded" when feature X is not even available in the current crate.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-diagnosticsArea: Messages for errors, warnings, and lintsA-lintsArea: Lints (warnings about flaws in source code) such as unused_mut.C-bugCategory: This is a bug.F-allow_internal_unstable`#![feature(allow_internal_unstable)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions