From 9dda6b5d35e6e8a1e405fa9b156dfaec67aef02d Mon Sep 17 00:00:00 2001 From: Eric Huss Date: Mon, 14 Aug 2023 12:05:53 -0700 Subject: [PATCH] Add test for unknown_lints from another file. --- .../unknown-lints/allow-in-other-module.rs | 26 +++++++++++++++++++ tests/ui/lint/unknown-lints/other.rs | 10 +++++++ 2 files changed, 36 insertions(+) create mode 100644 tests/ui/lint/unknown-lints/allow-in-other-module.rs create mode 100644 tests/ui/lint/unknown-lints/other.rs diff --git a/tests/ui/lint/unknown-lints/allow-in-other-module.rs b/tests/ui/lint/unknown-lints/allow-in-other-module.rs new file mode 100644 index 0000000000000..20bf0d7af03cb --- /dev/null +++ b/tests/ui/lint/unknown-lints/allow-in-other-module.rs @@ -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() {} diff --git a/tests/ui/lint/unknown-lints/other.rs b/tests/ui/lint/unknown-lints/other.rs new file mode 100644 index 0000000000000..a5111c00a3ecf --- /dev/null +++ b/tests/ui/lint/unknown-lints/other.rs @@ -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() {}