about summary refs log tree commit diff
path: root/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2024-10-20 16:34:35 +0000
committerbors <bors@rust-lang.org>2024-10-20 16:34:35 +0000
commitde977a5acf210f7d71ff83f4b8bc42c274ce4ed9 (patch)
tree0a0c48eb9dd8db5f171db1c74d9c09e6891d878c /tests
parentbfab34af4c5bfbcc9168064857bbec826a60a0b9 (diff)
parenta860657c0404dfe3297498176b21933836bd3358 (diff)
downloadrust-de977a5acf210f7d71ff83f4b8bc42c274ce4ed9.tar.gz
rust-de977a5acf210f7d71ff83f4b8bc42c274ce4ed9.zip
Auto merge of #131970 - matthiaskrgr:rollup-nr32ksd, r=matthiaskrgr
Rollup of 9 pull requests

Successful merges:

 - #121560 (Allow `#[deny]` inside `#[forbid]` as a no-op)
 - #131365 (Fix missing rustfmt in msi installer #101993)
 - #131647 (Register `src/tools/unicode-table-generator` as a runnable tool)
 - #131843 (compiler: Error on layout of enums with invalid reprs)
 - #131926 (Align boolean option descriptions in `configure.py`)
 - #131961 (compiletest: tidy up how `tidy` and `tidy` (html version) are disambiguated)
 - #131962 (Make `llvm::set_section` take a `&CStr`)
 - #131964 (add latest crash tests)
 - #131965 (remove outdated comment)

r? `@ghost`
`@rustbot` modify labels: rollup
Diffstat (limited to 'tests')
-rw-r--r--tests/crashes/131637.rs7
-rw-r--r--tests/crashes/131648.rs7
-rw-r--r--tests/crashes/131668.rs12
-rw-r--r--tests/crashes/131758.rs11
-rw-r--r--tests/crashes/131762.rs9
-rw-r--r--tests/crashes/131787.rs5
-rw-r--r--tests/crashes/131886.rs12
-rw-r--r--tests/crashes/131915.rs13
-rw-r--r--tests/ui/layout/thaw-transmute-invalid-enum.rs (renamed from tests/crashes/126966.rs)9
-rw-r--r--tests/ui/layout/thaw-transmute-invalid-enum.stderr68
-rw-r--r--tests/ui/layout/thaw-validate-invalid-enum.rs (renamed from tests/crashes/128870.rs)5
-rw-r--r--tests/ui/layout/thaw-validate-invalid-enum.stderr29
-rw-r--r--tests/ui/lint/auxiliary/allow-macro.rs7
-rw-r--r--tests/ui/lint/auxiliary/deny-macro.rs7
-rw-r--r--tests/ui/lint/auxiliary/forbid-macro.rs7
-rw-r--r--tests/ui/lint/auxiliary/warn-macro.rs7
-rw-r--r--tests/ui/lint/deny-inside-forbid-ignored.cli_forbid.stderr35
-rw-r--r--tests/ui/lint/deny-inside-forbid-ignored.cli_forbid_warnings.stderr35
-rw-r--r--tests/ui/lint/deny-inside-forbid-ignored.rs20
-rw-r--r--tests/ui/lint/deny-inside-forbid-ignored.source_only.stderr35
-rw-r--r--tests/ui/lint/forbid-macro-with-deny.allow.stderr26
-rw-r--r--tests/ui/lint/forbid-macro-with-deny.rs45
-rw-r--r--tests/ui/lint/forbid-macro-with-deny.warn.stderr26
-rw-r--r--tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs4
-rw-r--r--tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr5
-rw-r--r--tests/ui/lint/issue-80988.rs10
-rw-r--r--tests/ui/lint/issue-80988.stderr15
27 files changed, 438 insertions, 33 deletions
diff --git a/tests/crashes/131637.rs b/tests/crashes/131637.rs
new file mode 100644
index 00000000000..7d328384a74
--- /dev/null
+++ b/tests/crashes/131637.rs
@@ -0,0 +1,7 @@
+//@ known-bug: #121637
+#![feature(non_lifetime_binders)]
+trait Trait<Type> {
+    type Type;
+
+    fn method(&self) -> impl for<T> Trait<impl Trait<T>>;
+}
diff --git a/tests/crashes/131648.rs b/tests/crashes/131648.rs
new file mode 100644
index 00000000000..68046ce2a1f
--- /dev/null
+++ b/tests/crashes/131648.rs
@@ -0,0 +1,7 @@
+//@ known-bug: #131648
+#![feature(return_type_notation)]
+
+trait IntFactory {
+    fn stream(self) -> impl IntFactory<stream(..): Send>;
+}
+fn main() {}
diff --git a/tests/crashes/131668.rs b/tests/crashes/131668.rs
new file mode 100644
index 00000000000..90aa4494425
--- /dev/null
+++ b/tests/crashes/131668.rs
@@ -0,0 +1,12 @@
+//@ known-bug: #131668
+
+#![feature(generic_associated_types_extended)]
+trait B {
+    type Y<const N: i16>;
+}
+
+struct Erase<T: B>(T);
+
+fn make_static() {
+    Erase::<dyn for<'c> B<&'c ()>>(());
+}
diff --git a/tests/crashes/131758.rs b/tests/crashes/131758.rs
new file mode 100644
index 00000000000..942c5fd7a50
--- /dev/null
+++ b/tests/crashes/131758.rs
@@ -0,0 +1,11 @@
+//@ known-bug: #131758
+#![feature(unboxed_closures)]
+trait Foo {}
+
+impl<T: Fn<(i32,)>> Foo for T {}
+
+fn baz<T: Foo>(_: T) {}
+
+fn main() {
+    baz(|x| ());
+}
diff --git a/tests/crashes/131762.rs b/tests/crashes/131762.rs
new file mode 100644
index 00000000000..85cb9c8f20a
--- /dev/null
+++ b/tests/crashes/131762.rs
@@ -0,0 +1,9 @@
+//@ known-bug: #131762
+// ignore-tidy-linelength
+
+#![feature(generic_assert)]
+struct FloatWrapper(f64);
+
+fn main() {
+    assert!((0.0 / 0.0 >= 0.0) == (FloatWrapper(0.0 / 0.0) >= FloatWrapper(size_of::<u8>, size_of::<u16>, size_of::<usize> as fn() -> usize)))
+}
diff --git a/tests/crashes/131787.rs b/tests/crashes/131787.rs
new file mode 100644
index 00000000000..5c24ff8c143
--- /dev/null
+++ b/tests/crashes/131787.rs
@@ -0,0 +1,5 @@
+//@ known-bug: #131787
+#[track_caller]
+static no_mangle: u32 = {
+    unimplemented!();
+};
diff --git a/tests/crashes/131886.rs b/tests/crashes/131886.rs
new file mode 100644
index 00000000000..c31c2d6aa8b
--- /dev/null
+++ b/tests/crashes/131886.rs
@@ -0,0 +1,12 @@
+//@ known-bug: #131886
+//@ compile-flags: -Zvalidate-mir --crate-type=lib
+#![feature(trait_upcasting, type_alias_impl_trait)]
+
+type Tait = impl Sized;
+
+trait Foo<'a>: Bar<'a, 'a, Tait> {}
+trait Bar<'a, 'b, T> {}
+
+fn test_correct3<'a>(x: &dyn Foo<'a>, _: Tait) {
+    let _ = x as &dyn Bar<'_, '_, ()>;
+}
diff --git a/tests/crashes/131915.rs b/tests/crashes/131915.rs
new file mode 100644
index 00000000000..58d45adcb3b
--- /dev/null
+++ b/tests/crashes/131915.rs
@@ -0,0 +1,13 @@
+//@ known-bug: #131915
+
+macro_rules! y {
+    ( $($matcher:tt)*) => {
+        x
+    };
+}
+
+const _: A<
+    {
+        y! { test.tou8 }
+    },
+>;
diff --git a/tests/crashes/126966.rs b/tests/ui/layout/thaw-transmute-invalid-enum.rs
index 2c9f1a70f4f..835dcc04996 100644
--- a/tests/crashes/126966.rs
+++ b/tests/ui/layout/thaw-transmute-invalid-enum.rs
@@ -1,10 +1,14 @@
-//@ known-bug: rust-lang/rust#126966
+#![crate_type = "lib"]
+
 mod assert {
     use std::mem::{Assume, TransmuteFrom};
+    //~^ ERROR: use of unstable library feature 'transmutability'
+    //~| ERROR: use of unstable library feature 'transmutability'
 
     pub fn is_transmutable<Src, Dst>()
     where
         Dst: TransmuteFrom<Src>,
+        //~^ ERROR: use of unstable library feature 'transmutability'
     {
     }
 }
@@ -15,6 +19,7 @@ enum Ox00 {
 }
 
 #[repr(C, packed(2))]
+//~^ ERROR: attribute should be applied to a struct
 enum OxFF {
     V = 0xFF,
 }
@@ -22,8 +27,10 @@ enum OxFF {
 fn test() {
     union Superset {
         a: Ox00,
+        //~^ ERROR: field must implement `Copy`
         b: OxFF,
     }
 
     assert::is_transmutable::<Superset, Subset>();
+    //~^ ERROR: cannot find type `Subset`
 }
diff --git a/tests/ui/layout/thaw-transmute-invalid-enum.stderr b/tests/ui/layout/thaw-transmute-invalid-enum.stderr
new file mode 100644
index 00000000000..e6a5399c66b
--- /dev/null
+++ b/tests/ui/layout/thaw-transmute-invalid-enum.stderr
@@ -0,0 +1,68 @@
+error[E0412]: cannot find type `Subset` in this scope
+  --> $DIR/thaw-transmute-invalid-enum.rs:34:41
+   |
+LL |     assert::is_transmutable::<Superset, Subset>();
+   |                                         ^^^^^^ not found in this scope
+   |
+help: you might be missing a type parameter
+   |
+LL | fn test<Subset>() {
+   |        ++++++++
+
+error[E0517]: attribute should be applied to a struct or union
+  --> $DIR/thaw-transmute-invalid-enum.rs:21:11
+   |
+LL |   #[repr(C, packed(2))]
+   |             ^^^^^^^^^
+LL |
+LL | / enum OxFF {
+LL | |     V = 0xFF,
+LL | | }
+   | |_- not a struct or union
+
+error[E0658]: use of unstable library feature 'transmutability'
+  --> $DIR/thaw-transmute-invalid-enum.rs:4:20
+   |
+LL |     use std::mem::{Assume, TransmuteFrom};
+   |                    ^^^^^^
+   |
+   = note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information
+   = help: add `#![feature(transmutability)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+
+error[E0658]: use of unstable library feature 'transmutability'
+  --> $DIR/thaw-transmute-invalid-enum.rs:4:28
+   |
+LL |     use std::mem::{Assume, TransmuteFrom};
+   |                            ^^^^^^^^^^^^^
+   |
+   = note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information
+   = help: add `#![feature(transmutability)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+
+error[E0658]: use of unstable library feature 'transmutability'
+  --> $DIR/thaw-transmute-invalid-enum.rs:10:14
+   |
+LL |         Dst: TransmuteFrom<Src>,
+   |              ^^^^^^^^^^^^^^^^^^
+   |
+   = note: see issue #99571 <https://github.com/rust-lang/rust/issues/99571> for more information
+   = help: add `#![feature(transmutability)]` to the crate attributes to enable
+   = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
+
+error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
+  --> $DIR/thaw-transmute-invalid-enum.rs:29:9
+   |
+LL |         a: Ox00,
+   |         ^^^^^^^
+   |
+   = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`
+help: wrap the field type in `ManuallyDrop<...>`
+   |
+LL |         a: std::mem::ManuallyDrop<Ox00>,
+   |            +++++++++++++++++++++++    +
+
+error: aborting due to 6 previous errors
+
+Some errors have detailed explanations: E0412, E0517, E0658, E0740.
+For more information about an error, try `rustc --explain E0412`.
diff --git a/tests/crashes/128870.rs b/tests/ui/layout/thaw-validate-invalid-enum.rs
index 2b731962144..51aff7fb556 100644
--- a/tests/crashes/128870.rs
+++ b/tests/ui/layout/thaw-validate-invalid-enum.rs
@@ -1,7 +1,6 @@
-//@ known-bug: rust-lang/rust#128870
 //@ compile-flags: -Zvalidate-mir
 
-#[repr(packed)]
+#[repr(packed)] //~ ERROR: attribute should be applied to a struct
 #[repr(u32)]
 enum E {
     A,
@@ -12,7 +11,7 @@ enum E {
 fn main() {
     union InvalidTag {
         int: u32,
-        e: E,
+        e: E, //~ ERROR: field must implement `Copy`
     }
     let _invalid_tag = InvalidTag { int: 4 };
 }
diff --git a/tests/ui/layout/thaw-validate-invalid-enum.stderr b/tests/ui/layout/thaw-validate-invalid-enum.stderr
new file mode 100644
index 00000000000..9e522cba96a
--- /dev/null
+++ b/tests/ui/layout/thaw-validate-invalid-enum.stderr
@@ -0,0 +1,29 @@
+error[E0517]: attribute should be applied to a struct or union
+  --> $DIR/thaw-validate-invalid-enum.rs:3:8
+   |
+LL |   #[repr(packed)]
+   |          ^^^^^^
+LL |   #[repr(u32)]
+LL | / enum E {
+LL | |     A,
+LL | |     B,
+LL | |     C,
+LL | | }
+   | |_- not a struct or union
+
+error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union
+  --> $DIR/thaw-validate-invalid-enum.rs:14:9
+   |
+LL |         e: E,
+   |         ^^^^
+   |
+   = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>`
+help: wrap the field type in `ManuallyDrop<...>`
+   |
+LL |         e: std::mem::ManuallyDrop<E>,
+   |            +++++++++++++++++++++++ +
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0517, E0740.
+For more information about an error, try `rustc --explain E0517`.
diff --git a/tests/ui/lint/auxiliary/allow-macro.rs b/tests/ui/lint/auxiliary/allow-macro.rs
new file mode 100644
index 00000000000..35980e2e6ac
--- /dev/null
+++ b/tests/ui/lint/auxiliary/allow-macro.rs
@@ -0,0 +1,7 @@
+#[macro_export]
+macro_rules! emit_allow {
+    () => {
+        #[allow(unsafe_code)]
+        let _so_safe = 0;
+    };
+}
diff --git a/tests/ui/lint/auxiliary/deny-macro.rs b/tests/ui/lint/auxiliary/deny-macro.rs
new file mode 100644
index 00000000000..6106cd0ef17
--- /dev/null
+++ b/tests/ui/lint/auxiliary/deny-macro.rs
@@ -0,0 +1,7 @@
+#[macro_export]
+macro_rules! emit_deny {
+    () => {
+        #[deny(unsafe_code)]
+        let _so_safe = 0;
+    };
+}
diff --git a/tests/ui/lint/auxiliary/forbid-macro.rs b/tests/ui/lint/auxiliary/forbid-macro.rs
new file mode 100644
index 00000000000..aa74d0cf314
--- /dev/null
+++ b/tests/ui/lint/auxiliary/forbid-macro.rs
@@ -0,0 +1,7 @@
+#[macro_export]
+macro_rules! emit_forbid {
+    () => {
+        #[forbid(unsafe_code)]
+        let _so_safe = 0;
+    };
+}
diff --git a/tests/ui/lint/auxiliary/warn-macro.rs b/tests/ui/lint/auxiliary/warn-macro.rs
new file mode 100644
index 00000000000..8216b65c74b
--- /dev/null
+++ b/tests/ui/lint/auxiliary/warn-macro.rs
@@ -0,0 +1,7 @@
+#[macro_export]
+macro_rules! emit_warn {
+    () => {
+        #[warn(unsafe_code)]
+        let _so_safe = 0;
+    };
+}
diff --git a/tests/ui/lint/deny-inside-forbid-ignored.cli_forbid.stderr b/tests/ui/lint/deny-inside-forbid-ignored.cli_forbid.stderr
new file mode 100644
index 00000000000..06086cbef8a
--- /dev/null
+++ b/tests/ui/lint/deny-inside-forbid-ignored.cli_forbid.stderr
@@ -0,0 +1,35 @@
+error[E0453]: allow(unsafe_code) incompatible with previous forbid
+  --> $DIR/deny-inside-forbid-ignored.rs:12:17
+   |
+LL | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
+   |          ----------- `forbid` level set here
+...
+LL |         #[allow(unsafe_code)] // let's have some unsafe code in here
+   |                 ^^^^^^^^^^^ overruled by previous forbid
+
+error[E0453]: allow(unsafe_code) incompatible with previous forbid
+  --> $DIR/deny-inside-forbid-ignored.rs:12:17
+   |
+LL | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
+   |          ----------- `forbid` level set here
+...
+LL |         #[allow(unsafe_code)] // let's have some unsafe code in here
+   |                 ^^^^^^^^^^^ overruled by previous forbid
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: usage of an `unsafe` block
+  --> $DIR/deny-inside-forbid-ignored.rs:16:13
+   |
+LL |             unsafe { /* ≽^•⩊•^≼ */ }
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/deny-inside-forbid-ignored.rs:8:10
+   |
+LL | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
+   |          ^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0453`.
diff --git a/tests/ui/lint/deny-inside-forbid-ignored.cli_forbid_warnings.stderr b/tests/ui/lint/deny-inside-forbid-ignored.cli_forbid_warnings.stderr
new file mode 100644
index 00000000000..06086cbef8a
--- /dev/null
+++ b/tests/ui/lint/deny-inside-forbid-ignored.cli_forbid_warnings.stderr
@@ -0,0 +1,35 @@
+error[E0453]: allow(unsafe_code) incompatible with previous forbid
+  --> $DIR/deny-inside-forbid-ignored.rs:12:17
+   |
+LL | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
+   |          ----------- `forbid` level set here
+...
+LL |         #[allow(unsafe_code)] // let's have some unsafe code in here
+   |                 ^^^^^^^^^^^ overruled by previous forbid
+
+error[E0453]: allow(unsafe_code) incompatible with previous forbid
+  --> $DIR/deny-inside-forbid-ignored.rs:12:17
+   |
+LL | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
+   |          ----------- `forbid` level set here
+...
+LL |         #[allow(unsafe_code)] // let's have some unsafe code in here
+   |                 ^^^^^^^^^^^ overruled by previous forbid
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: usage of an `unsafe` block
+  --> $DIR/deny-inside-forbid-ignored.rs:16:13
+   |
+LL |             unsafe { /* ≽^•⩊•^≼ */ }
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/deny-inside-forbid-ignored.rs:8:10
+   |
+LL | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
+   |          ^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0453`.
diff --git a/tests/ui/lint/deny-inside-forbid-ignored.rs b/tests/ui/lint/deny-inside-forbid-ignored.rs
new file mode 100644
index 00000000000..b14a3e94bb5
--- /dev/null
+++ b/tests/ui/lint/deny-inside-forbid-ignored.rs
@@ -0,0 +1,20 @@
+//! Ensure that using deny inside forbid is treated as a no-op, and does not override the level to
+//! deny.
+
+//@ revisions: source_only cli_forbid cli_forbid_warnings
+//@[cli_forbid] compile-flags: -F unsafe_code
+//@[cli_forbid_warnings] compile-flags: -F warnings
+
+#[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
+fn main() {
+    #[deny(unsafe_code)] // m-m-maybe we can have unsafe code in here?
+    {
+        #[allow(unsafe_code)] // let's have some unsafe code in here
+        //~^ ERROR allow(unsafe_code) incompatible with previous forbid
+        //~| ERROR allow(unsafe_code) incompatible with previous forbid
+        {
+            unsafe { /* ≽^•⩊•^≼ */ }
+            //~^ ERROR usage of an `unsafe` block
+        }
+    }
+}
diff --git a/tests/ui/lint/deny-inside-forbid-ignored.source_only.stderr b/tests/ui/lint/deny-inside-forbid-ignored.source_only.stderr
new file mode 100644
index 00000000000..06086cbef8a
--- /dev/null
+++ b/tests/ui/lint/deny-inside-forbid-ignored.source_only.stderr
@@ -0,0 +1,35 @@
+error[E0453]: allow(unsafe_code) incompatible with previous forbid
+  --> $DIR/deny-inside-forbid-ignored.rs:12:17
+   |
+LL | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
+   |          ----------- `forbid` level set here
+...
+LL |         #[allow(unsafe_code)] // let's have some unsafe code in here
+   |                 ^^^^^^^^^^^ overruled by previous forbid
+
+error[E0453]: allow(unsafe_code) incompatible with previous forbid
+  --> $DIR/deny-inside-forbid-ignored.rs:12:17
+   |
+LL | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
+   |          ----------- `forbid` level set here
+...
+LL |         #[allow(unsafe_code)] // let's have some unsafe code in here
+   |                 ^^^^^^^^^^^ overruled by previous forbid
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+
+error: usage of an `unsafe` block
+  --> $DIR/deny-inside-forbid-ignored.rs:16:13
+   |
+LL |             unsafe { /* ≽^•⩊•^≼ */ }
+   |             ^^^^^^^^^^^^^^^^^^^^^^^^
+   |
+note: the lint level is defined here
+  --> $DIR/deny-inside-forbid-ignored.rs:8:10
+   |
+LL | #[forbid(unsafe_code)] // NO UNSAFE CODE IN HERE!!
+   |          ^^^^^^^^^^^
+
+error: aborting due to 3 previous errors
+
+For more information about this error, try `rustc --explain E0453`.
diff --git a/tests/ui/lint/forbid-macro-with-deny.allow.stderr b/tests/ui/lint/forbid-macro-with-deny.allow.stderr
new file mode 100644
index 00000000000..77735c1c5d3
--- /dev/null
+++ b/tests/ui/lint/forbid-macro-with-deny.allow.stderr
@@ -0,0 +1,26 @@
+error[E0453]: allow(unsafe_code) incompatible with previous forbid
+  --> $DIR/forbid-macro-with-deny.rs:39:5
+   |
+LL | #![forbid(unsafe_code)]
+   |           ----------- `forbid` level set here
+...
+LL |     allow_macro::emit_allow! {}
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ overruled by previous forbid
+   |
+   = note: this error originates in the macro `allow_macro::emit_allow` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0453]: allow(unsafe_code) incompatible with previous forbid
+  --> $DIR/forbid-macro-with-deny.rs:39:5
+   |
+LL | #![forbid(unsafe_code)]
+   |           ----------- `forbid` level set here
+...
+LL |     allow_macro::emit_allow! {}
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^ overruled by previous forbid
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+   = note: this error originates in the macro `allow_macro::emit_allow` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0453`.
diff --git a/tests/ui/lint/forbid-macro-with-deny.rs b/tests/ui/lint/forbid-macro-with-deny.rs
new file mode 100644
index 00000000000..85f67ea3631
--- /dev/null
+++ b/tests/ui/lint/forbid-macro-with-deny.rs
@@ -0,0 +1,45 @@
+//! Ensure that when a macro (or normal code) does `#[deny]` inside a `#[forbid]` context, no error
+//! is emitted, as both parties agree on the treatment of the lint.
+//!
+//! However, still emit an error if the macro does `#[allow]` or `#[warn]`.
+
+//@ revisions: forbid deny warn allow
+//@[forbid] aux-build:forbid-macro.rs
+//@[deny] aux-build:deny-macro.rs
+//@[warn] aux-build:warn-macro.rs
+//@[allow] aux-build:allow-macro.rs
+
+//@[forbid] check-pass
+//@[deny] check-pass
+
+#![forbid(unsafe_code)]
+
+#[cfg(allow)]
+extern crate allow_macro;
+#[cfg(deny)]
+extern crate deny_macro;
+#[cfg(forbid)]
+extern crate forbid_macro;
+#[cfg(warn)]
+extern crate warn_macro;
+
+fn main() {
+    #[cfg(forbid)]
+    forbid_macro::emit_forbid! {} // OK
+
+    #[cfg(deny)]
+    deny_macro::emit_deny! {} // OK
+
+    #[cfg(warn)]
+    warn_macro::emit_warn! {}
+    //[warn]~^ ERROR warn(unsafe_code) incompatible with previous forbid
+    //[warn]~| ERROR warn(unsafe_code) incompatible with previous forbid
+
+    #[cfg(allow)]
+    allow_macro::emit_allow! {}
+    //[allow]~^ ERROR allow(unsafe_code) incompatible with previous forbid
+    //[allow]~| ERROR allow(unsafe_code) incompatible with previous forbid
+
+    #[deny(unsafe_code)] // OK
+    let _ = 0;
+}
diff --git a/tests/ui/lint/forbid-macro-with-deny.warn.stderr b/tests/ui/lint/forbid-macro-with-deny.warn.stderr
new file mode 100644
index 00000000000..10452ebd1b6
--- /dev/null
+++ b/tests/ui/lint/forbid-macro-with-deny.warn.stderr
@@ -0,0 +1,26 @@
+error[E0453]: warn(unsafe_code) incompatible with previous forbid
+  --> $DIR/forbid-macro-with-deny.rs:34:5
+   |
+LL | #![forbid(unsafe_code)]
+   |           ----------- `forbid` level set here
+...
+LL |     warn_macro::emit_warn! {}
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ overruled by previous forbid
+   |
+   = note: this error originates in the macro `warn_macro::emit_warn` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error[E0453]: warn(unsafe_code) incompatible with previous forbid
+  --> $DIR/forbid-macro-with-deny.rs:34:5
+   |
+LL | #![forbid(unsafe_code)]
+   |           ----------- `forbid` level set here
+...
+LL |     warn_macro::emit_warn! {}
+   |     ^^^^^^^^^^^^^^^^^^^^^^^^^ overruled by previous forbid
+   |
+   = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
+   = note: this error originates in the macro `warn_macro::emit_warn` (in Nightly builds, run with -Z macro-backtrace for more info)
+
+error: aborting due to 2 previous errors
+
+For more information about this error, try `rustc --explain E0453`.
diff --git a/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs b/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs
index 37d96129317..45b78d75b27 100644
--- a/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs
+++ b/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.rs
@@ -19,9 +19,9 @@
 fn forbid_first(num: i32) -> i32 {
     #![forbid(unused)]
     #![deny(unused)]
-    //~^ ERROR: deny(unused) incompatible with previous forbid
-    //~| WARNING being phased out
     #![warn(unused)]
+    //~^ ERROR: warn(unused) incompatible with previous forbid
+    //~| WARNING being phased out
     #![allow(unused)]
 
     num * num
diff --git a/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr b/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr
index f78bf899b84..407eaf1c60a 100644
--- a/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr
+++ b/tests/ui/lint/issue-70819-dont-override-forbid-in-same-scope.stderr
@@ -1,9 +1,10 @@
-error: deny(unused) incompatible with previous forbid
-  --> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:21:13
+error: warn(unused) incompatible with previous forbid
+  --> $DIR/issue-70819-dont-override-forbid-in-same-scope.rs:22:13
    |
 LL |     #![forbid(unused)]
    |               ------ `forbid` level set here
 LL |     #![deny(unused)]
+LL |     #![warn(unused)]
    |             ^^^^^^ overruled by previous forbid
    |
    = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
diff --git a/tests/ui/lint/issue-80988.rs b/tests/ui/lint/issue-80988.rs
deleted file mode 100644
index 80decd8e736..00000000000
--- a/tests/ui/lint/issue-80988.rs
+++ /dev/null
@@ -1,10 +0,0 @@
-// Regression test for #80988
-//
-//@ check-pass
-
-#![forbid(warnings)]
-
-#[deny(warnings)]
-//~^ WARNING incompatible with previous forbid
-//~| WARNING being phased out
-fn main() {}
diff --git a/tests/ui/lint/issue-80988.stderr b/tests/ui/lint/issue-80988.stderr
deleted file mode 100644
index afc93fcfeef..00000000000
--- a/tests/ui/lint/issue-80988.stderr
+++ /dev/null
@@ -1,15 +0,0 @@
-warning: deny(warnings) incompatible with previous forbid
-  --> $DIR/issue-80988.rs:7:8
-   |
-LL | #![forbid(warnings)]
-   |           -------- `forbid` level set here
-LL |
-LL | #[deny(warnings)]
-   |        ^^^^^^^^ overruled by previous forbid
-   |
-   = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
-   = note: for more information, see issue #81670 <https://github.com/rust-lang/rust/issues/81670>
-   = note: `#[warn(forbidden_lint_groups)]` on by default
-
-warning: 1 warning emitted
-