rust-lang / rust-lang/rust

Undefined lints scoped under `rustc` don't result in lint unknown-lints getting emitted (unless `-Zunstable-options` is passed)

Open
#138,788 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

While undefined "unscoped" lints lead to the compiler emitting the warn-by-default lint unknown-lints

#![allow(undefined)] //~ WARN unknown lint `undefined`
warning: unknown lint: `undefined`
 --> src/lib.rs:1:10
  |
1 | #![allow(undefined)]
  |          ^^^^^^^^^
  |
  = note: `#[warn(unknown_lints)]` on by default

the same doesn't happen for undefined lints scoped under rustc:

//@ check-pass
#![deny(unknown_lints)]

#![allow(rustc::undefined)]

It would be beneficial if rustc would emit unknown_lints in these cases.

Built-in tools like rustfmt and clippy or tools defined via register_tool are responsible for dealing with undefined lints themselves. However, the tool modules lint scope rustc is owned by rustc and should therefore do the checking.

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 two lint examples in the issue and compare the diagnostics with and without -Zunstable-options. Trace rustc's handling of the rustc lint scope and the unknown-lints diagnostic, then add or update a compiler test demonstrating the expected warning for rustc::undefined. Done means rustc emits unknown-lints for undefined lints scoped under rustc without requiring unstable options.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.