Skip to content

Commit

Permalink
Rollup merge of #114820 - ehuss:unknown-lint-mod-warning, r=compiler-…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
GuillaumeGomez committed Aug 15, 2023
2 parents f527d56 + 9dda6b5 commit dd76268
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
26 changes: 26 additions & 0 deletions tests/ui/lint/unknown-lints/allow-in-other-module.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// check-pass

// Tests that the unknown_lints lint doesn't fire for an unknown lint loaded from a separate file.
// The key part is that the stderr output should be empty.
// Reported in https://github.com/rust-lang/rust/issues/84936
// Fixed incidentally by https://github.com/rust-lang/rust/pull/97266

// This `allow` should apply to submodules, whether they are inline or loaded from a file.
#![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() {}
}

fn main() {}
10 changes: 10 additions & 0 deletions tests/ui/lint/unknown-lints/other.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// ignore-test

// Companion to allow-in-other-module.rs

// This should not warn.
#![allow(not_a_real_lint)]

// This should not warn, either.
#[allow(not_a_real_lint)]
fn m() {}

0 comments on commit dd76268

Please sign in to comment.