summaryrefslogtreecommitdiffstats
path: root/tests/ui/lint/outer-forbid.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 12:19:13 +0000
commit218caa410aa38c29984be31a5229b9fa717560ee (patch)
treec54bd55eeb6e4c508940a30e94c0032fbd45d677 /tests/ui/lint/outer-forbid.rs
parentReleasing progress-linux version 1.67.1+dfsg1-1~progress7.99u1. (diff)
downloadrustc-218caa410aa38c29984be31a5229b9fa717560ee.tar.xz
rustc-218caa410aa38c29984be31a5229b9fa717560ee.zip
Merging upstream version 1.68.2+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ui/lint/outer-forbid.rs')
-rw-r--r--tests/ui/lint/outer-forbid.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/ui/lint/outer-forbid.rs b/tests/ui/lint/outer-forbid.rs
new file mode 100644
index 000000000..ba330258d
--- /dev/null
+++ b/tests/ui/lint/outer-forbid.rs
@@ -0,0 +1,32 @@
+// Forbidding a group (here, `unused`) overrules subsequent allowance of both
+// the group, and an individual lint in the group (here, `unused_variables`);
+// and, forbidding an individual lint (here, `non_snake_case`) overrules
+// subsequent allowance of a lint group containing it (here, `nonstandard_style`). See
+// Issue #42873.
+
+// If you turn off deduplicate diagnostics (which rustc turns on by default but
+// compiletest turns off when it runs ui tests), then the errors are
+// (unfortunately) repeated here because the checking is done as we read in the
+// errors, and currently that happens two or three different times, depending on
+// compiler flags.
+//
+// The test is much cleaner if we deduplicate, though.
+
+// compile-flags: -Z deduplicate-diagnostics=yes
+
+#![forbid(unused, non_snake_case)]
+#![forbid(forbidden_lint_groups)]
+
+#[allow(unused_variables)]
+//~^ ERROR incompatible with previous
+//~| WARNING this was previously accepted by the compiler
+fn foo() {}
+
+#[allow(unused)] //~ ERROR incompatible with previous
+//~^ WARNING this was previously accepted by the compiler
+fn bar() {}
+
+#[allow(nonstandard_style)] //~ ERROR incompatible with previous
+fn main() {
+ println!("hello forbidden world")
+}