Closed
Description
It seems like #![allow(unknown_lints)]
only works in the same file where it was added, and not in any sub modules in other files.
lib.rs:
#![allow(unknown_lints)]
#![allow(dead_code)]
// no warning
#![allow(not_a_real_lint)]
mod other;
// no warning
#[allow(not_a_real_lint)]
fn m() {}
mod mm {
// no warning
#[allow(not_a_real_lint)]
fn m() {}
}
other.rs
// warning: unknown lint: `not_a_real_lint`
#![allow(not_a_real_lint)]
// warning: unknown lint: `not_a_real_lint`
#[allow(not_a_real_lint)]
fn m() {}
I expected to see this happen:
No warnings in other.rs about unknown lints
Instead, this happened:
Warnings about unknown lints in other.rs
warning: unknown lint: `not_a_real_lint`
--> src\other.rs:2:10
|
2 | #![allow(not_a_real_lint)]
| ^^^^^^^^^^^^^^^
|
= note: `#[warn(unknown_lints)]` on by default
warning: unknown lint: `not_a_real_lint`
--> src\other.rs:5:9
|
5 | #[allow(not_a_real_lint)]
| ^^^^^^^^^^^^^^^
warning: unknown lint: `not_a_real_lint`
--> src\other.rs:2:10
|
2 | #![allow(not_a_real_lint)]
| ^^^^^^^^^^^^^^^
warning: 3 warnings emitted
Meta
rustc --version --verbose
:
rustc 1.51.0 (2fd73fabe 2021-03-23)
binary: rustc
commit-hash: 2fd73fabe469357a12c2c974c140f67e7cdd76d0
commit-date: 2021-03-23
host: x86_64-pc-windows-msvc
release: 1.51.0
LLVM version: 11.0.1
Also repros with 1.52.0 beta.