rust-lang / rust-lang/rust

`allow_internal_unstable` can be used to bypass `incomplete_features` warning

Open
#128,175 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

A-diagnostics A-lints C-bug F-allow_internal_unstable T-compiler
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the provided macro example and inspect how the incomplete_features lint handles module-level feature declarations, allow_internal_unstable, and rustc_allow_const_fn_unstable. Determine whether the lint should inspect those attributes or restrict macro allowances to features enabled in the declaring crate; done means the policy is resolved and the example no longer bypasses the intended warning.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.