Skip to content

Commit dd76268

Browse files
Rollup merge of #114820 - ehuss:unknown-lint-mod-warning, r=compiler-errors
Add test for unknown_lints from another file. This adds a test for #84936 which was incidentally fixed via #97266. It is a strange issue where `#![allow(unknown_lints)]` at the crate root was not applying to unknown lints that fired in a non-inline-module. I did not dig further into how #97266 fixed it, but I did verify it. I couldn't find any existing tests which did anything similar. Closes #84936
2 parents f527d56 + 9dda6b5 commit dd76268

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// check-pass
2+
3+
// Tests that the unknown_lints lint doesn't fire for an unknown lint loaded from a separate file.
4+
// The key part is that the stderr output should be empty.
5+
// Reported in https://github.com/rust-lang/rust/issues/84936
6+
// Fixed incidentally by https://github.com/rust-lang/rust/pull/97266
7+
8+
// This `allow` should apply to submodules, whether they are inline or loaded from a file.
9+
#![allow(unknown_lints)]
10+
#![allow(dead_code)]
11+
// no warning
12+
#![allow(not_a_real_lint)]
13+
14+
mod other;
15+
16+
// no warning
17+
#[allow(not_a_real_lint)]
18+
fn m() {}
19+
20+
mod mm {
21+
// no warning
22+
#[allow(not_a_real_lint)]
23+
fn m() {}
24+
}
25+
26+
fn main() {}

tests/ui/lint/unknown-lints/other.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// ignore-test
2+
3+
// Companion to allow-in-other-module.rs
4+
5+
// This should not warn.
6+
#![allow(not_a_real_lint)]
7+
8+
// This should not warn, either.
9+
#[allow(not_a_real_lint)]
10+
fn m() {}

0 commit comments

Comments
 (0)