about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEric Huss <eric@huss.org>2023-08-14 12:05:53 -0700
committerEric Huss <eric@huss.org>2023-08-14 12:05:53 -0700
commit9dda6b5d35e6e8a1e405fa9b156dfaec67aef02d (patch)
tree2d3968b8b5a2feedcbe99327cedf21c1cb113227
parent475be26d99b8e3898c482e0ac42ab7bce3d511bf (diff)
downloadrust-9dda6b5d35e6e8a1e405fa9b156dfaec67aef02d.tar.gz
rust-9dda6b5d35e6e8a1e405fa9b156dfaec67aef02d.zip
Add test for unknown_lints from another file.
-rw-r--r--tests/ui/lint/unknown-lints/allow-in-other-module.rs26
-rw-r--r--tests/ui/lint/unknown-lints/other.rs10
2 files changed, 36 insertions, 0 deletions
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 00000000000..20bf0d7af03
--- /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 00000000000..a5111c00a3e
--- /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() {}