Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow_internal_unstable can be used to bypass incomplete_features warning #128175

Open
RalfJung opened this issue Jul 25, 2024 · 0 comments
Open
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@RalfJung
Copy link
Member

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.

@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Jul 25, 2024
@saethlin saethlin added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. C-bug Category: This is a bug. and removed needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. labels Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

3 participants