about summary refs log tree commit diff
path: root/tests/ui/pattern
diff options
context:
space:
mode:
authorTshepang Mbambo <tshepang@gmail.com>2025-04-19 16:06:07 +0200
committerGitHub <noreply@github.com>2025-04-19 16:06:07 +0200
commitb886a8e654ab660f2f2cd02c68bf170dd4918fd8 (patch)
tree86e6a9ab8518740ca6ce8deae8f409ee9c309f20 /tests/ui/pattern
parent52616fa902a9a551ba4e574bee41dbf6162746f4 (diff)
parent07b7f00a9e961fdf66ece2ecf70ae1dba505f10e (diff)
Merge pull request #2347 from rust-lang/rustc-pull
Rustc pull update
Diffstat (limited to 'tests/ui/pattern')
-rw-r--r--tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs6
-rw-r--r--tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr2
-rw-r--r--tests/ui/pattern/bindings-after-at/wild-before-at-syntactically-rejected.rs2
-rw-r--r--tests/ui/pattern/deref-patterns/bindings.rs55
-rw-r--r--tests/ui/pattern/deref-patterns/branch.rs22
-rw-r--r--tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.rs18
-rw-r--r--tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.stderr36
-rw-r--r--tests/ui/pattern/deref-patterns/closure_capture.rs27
-rw-r--r--tests/ui/pattern/deref-patterns/fake_borrows.rs7
-rw-r--r--tests/ui/pattern/deref-patterns/fake_borrows.stderr11
-rw-r--r--tests/ui/pattern/deref-patterns/implicit-const-deref.rs19
-rw-r--r--tests/ui/pattern/deref-patterns/implicit-const-deref.stderr16
-rw-r--r--tests/ui/pattern/deref-patterns/implicit-cow-deref.rs45
-rw-r--r--tests/ui/pattern/deref-patterns/needs-gate.rs15
-rw-r--r--tests/ui/pattern/deref-patterns/needs-gate.stderr29
-rw-r--r--tests/ui/pattern/deref-patterns/recursion-limit.rs23
-rw-r--r--tests/ui/pattern/deref-patterns/recursion-limit.stderr18
-rw-r--r--tests/ui/pattern/deref-patterns/ref-mut.rs9
-rw-r--r--tests/ui/pattern/deref-patterns/ref-mut.stderr10
-rw-r--r--tests/ui/pattern/deref-patterns/typeck.rs6
-rw-r--r--tests/ui/pattern/deref-patterns/typeck_fail.rs11
-rw-r--r--tests/ui/pattern/deref-patterns/typeck_fail.stderr36
-rw-r--r--tests/ui/pattern/deref-patterns/unsatisfied-bounds.rs21
-rw-r--r--tests/ui/pattern/deref-patterns/unsatisfied-bounds.stderr9
-rw-r--r--tests/ui/pattern/non-structural-match-types-cycle-err.rs24
-rw-r--r--tests/ui/pattern/non-structural-match-types-cycle-err.stderr64
-rw-r--r--tests/ui/pattern/non-structural-match-types.rs8
-rw-r--r--tests/ui/pattern/non-structural-match-types.stderr22
-rw-r--r--tests/ui/pattern/patkind-ref-binding-issue-114896.fixed2
-rw-r--r--tests/ui/pattern/patkind-ref-binding-issue-114896.rs2
-rw-r--r--tests/ui/pattern/rest-pat-syntactic.rs2
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs6
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.rs2
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.rs36
-rw-r--r--tests/ui/pattern/usefulness/doc-hidden-fields.rs8
-rw-r--r--tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs10
-rw-r--r--tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs24
-rw-r--r--tests/ui/pattern/usefulness/stable-gated-fields.rs4
-rw-r--r--tests/ui/pattern/usefulness/stable-gated-patterns.rs4
-rw-r--r--tests/ui/pattern/usefulness/unstable-gated-fields.rs4
-rw-r--r--tests/ui/pattern/usefulness/unstable-gated-patterns.rs2
41 files changed, 586 insertions, 91 deletions
diff --git a/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs b/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs
index 01a978d5557..9582d2729a8 100644
--- a/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs
+++ b/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.rs
@@ -13,19 +13,19 @@ fn _ok() {
     fn _f(_a @ _b: u8) {} // OK.
 }
 
-#[cfg(FALSE)]
+#[cfg(false)]
 fn case_1() {
     let a: u8 @ b = 0;
     //~^ ERROR expected one of `!`
 }
 
-#[cfg(FALSE)]
+#[cfg(false)]
 fn case_2() {
     let a @ (b: u8);
     //~^ ERROR expected one of `)`
 }
 
-#[cfg(FALSE)]
+#[cfg(false)]
 fn case_3() {
     let a: T1 @ Outer(b: T2);
     //~^ ERROR expected one of `!`
diff --git a/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr b/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr
index 6ce8f6d31a0..1847e407f6b 100644
--- a/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr
+++ b/tests/ui/pattern/bindings-after-at/nested-type-ascription-syntactically-invalid.stderr
@@ -11,8 +11,6 @@ error: expected one of `)`, `,`, `@`, `if`, or `|`, found `:`
    |
 LL |     let a @ (b: u8);
    |               ^ expected one of `)`, `,`, `@`, `if`, or `|`
-   |
-   = note: type ascription syntax has been removed, see issue #101728 <https://github.com/rust-lang/rust/issues/101728>
 
 error: expected one of `!`, `(`, `+`, `::`, `;`, `<`, or `=`, found `@`
   --> $DIR/nested-type-ascription-syntactically-invalid.rs:30:15
diff --git a/tests/ui/pattern/bindings-after-at/wild-before-at-syntactically-rejected.rs b/tests/ui/pattern/bindings-after-at/wild-before-at-syntactically-rejected.rs
index 50ac0ef2783..c3994d35c42 100644
--- a/tests/ui/pattern/bindings-after-at/wild-before-at-syntactically-rejected.rs
+++ b/tests/ui/pattern/bindings-after-at/wild-before-at-syntactically-rejected.rs
@@ -3,7 +3,7 @@
 
 fn main() {}
 
-#[cfg(FALSE)]
+#[cfg(false)]
 fn wild_before_at_is_bad_syntax() {
     let _ @ a = 0;
     //~^ ERROR pattern on wrong side of `@`
diff --git a/tests/ui/pattern/deref-patterns/bindings.rs b/tests/ui/pattern/deref-patterns/bindings.rs
index 5881e4166a4..c14d57f3f24 100644
--- a/tests/ui/pattern/deref-patterns/bindings.rs
+++ b/tests/ui/pattern/deref-patterns/bindings.rs
@@ -1,7 +1,9 @@
+//@ revisions: explicit implicit
 //@ run-pass
 #![feature(deref_patterns)]
 #![allow(incomplete_features)]
 
+#[cfg(explicit)]
 fn simple_vec(vec: Vec<u32>) -> u32 {
     match vec {
         deref!([]) => 100,
@@ -13,6 +15,19 @@ fn simple_vec(vec: Vec<u32>) -> u32 {
     }
 }
 
+#[cfg(implicit)]
+fn simple_vec(vec: Vec<u32>) -> u32 {
+    match vec {
+        [] => 100,
+        [x] if x == 4 => x + 4,
+        [x] => x,
+        [1, x] => x + 200,
+        deref!(ref slice) => slice.iter().sum(),
+        _ => 2000,
+    }
+}
+
+#[cfg(explicit)]
 fn nested_vec(vecvec: Vec<Vec<u32>>) -> u32 {
     match vecvec {
         deref!([]) => 0,
@@ -24,6 +39,19 @@ fn nested_vec(vecvec: Vec<Vec<u32>>) -> u32 {
     }
 }
 
+#[cfg(implicit)]
+fn nested_vec(vecvec: Vec<Vec<u32>>) -> u32 {
+    match vecvec {
+        [] => 0,
+        [[x]] => x,
+        [[0, x] | [1, x]] => x,
+        [ref x] => x.iter().sum(),
+        [[], [1, x, y]] => y - x,
+        _ => 2000,
+    }
+}
+
+#[cfg(explicit)]
 fn ref_mut(val: u32) -> u32 {
     let mut b = Box::new(0u32);
     match &mut b {
@@ -37,6 +65,21 @@ fn ref_mut(val: u32) -> u32 {
     *x
 }
 
+#[cfg(implicit)]
+fn ref_mut(val: u32) -> u32 {
+    let mut b = Box::new((0u32,));
+    match &mut b {
+        (_x,) if false => unreachable!(),
+        (x,) => {
+            *x = val;
+        }
+        _ => unreachable!(),
+    }
+    let (x,) = &b else { unreachable!() };
+    *x
+}
+
+#[cfg(explicit)]
 #[rustfmt::skip]
 fn or_and_guard(tuple: (u32, u32)) -> u32 {
     let mut sum = 0;
@@ -48,6 +91,18 @@ fn or_and_guard(tuple: (u32, u32)) -> u32 {
     sum
 }
 
+#[cfg(implicit)]
+#[rustfmt::skip]
+fn or_and_guard(tuple: (u32, u32)) -> u32 {
+    let mut sum = 0;
+    let b = Box::new(tuple);
+    match b {
+        (x, _) | (_, x) if { sum += x; false } => {},
+        _ => {},
+    }
+    sum
+}
+
 fn main() {
     assert_eq!(simple_vec(vec![1]), 1);
     assert_eq!(simple_vec(vec![1, 2]), 202);
diff --git a/tests/ui/pattern/deref-patterns/branch.rs b/tests/ui/pattern/deref-patterns/branch.rs
index 1bac1006d9d..9d72b35fd2f 100644
--- a/tests/ui/pattern/deref-patterns/branch.rs
+++ b/tests/ui/pattern/deref-patterns/branch.rs
@@ -1,8 +1,10 @@
+//@ revisions: explicit implicit
 //@ run-pass
 // Test the execution of deref patterns.
 #![feature(deref_patterns)]
 #![allow(incomplete_features)]
 
+#[cfg(explicit)]
 fn branch(vec: Vec<u32>) -> u32 {
     match vec {
         deref!([]) => 0,
@@ -12,6 +14,17 @@ fn branch(vec: Vec<u32>) -> u32 {
     }
 }
 
+#[cfg(implicit)]
+fn branch(vec: Vec<u32>) -> u32 {
+    match vec {
+        [] => 0,
+        [1, _, 3] => 1,
+        [2, ..] => 2,
+        _ => 1000,
+    }
+}
+
+#[cfg(explicit)]
 fn nested(vec: Vec<Vec<u32>>) -> u32 {
     match vec {
         deref!([deref!([]), ..]) => 1,
@@ -20,6 +33,15 @@ fn nested(vec: Vec<Vec<u32>>) -> u32 {
     }
 }
 
+#[cfg(implicit)]
+fn nested(vec: Vec<Vec<u32>>) -> u32 {
+    match vec {
+        [[], ..] => 1,
+        [[0, ..], [1, ..]] => 2,
+        _ => 1000,
+    }
+}
+
 fn main() {
     assert!(matches!(Vec::<u32>::new(), deref!([])));
     assert!(matches!(vec![1], deref!([1])));
diff --git a/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.rs b/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.rs
index 84b5ec09dc7..791776be5ac 100644
--- a/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.rs
+++ b/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.rs
@@ -21,4 +21,22 @@ fn cant_move_out_rc(rc: Rc<Struct>) -> Struct {
     }
 }
 
+struct Container(Struct);
+
+fn cant_move_out_box_implicit(b: Box<Container>) -> Struct {
+    match b {
+        //~^ ERROR: cannot move out of a shared reference
+        Container(x) => x,
+        _ => unreachable!(),
+    }
+}
+
+fn cant_move_out_rc_implicit(rc: Rc<Container>) -> Struct {
+    match rc {
+        //~^ ERROR: cannot move out of a shared reference
+        Container(x) => x,
+        _ => unreachable!(),
+    }
+}
+
 fn main() {}
diff --git a/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.stderr b/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.stderr
index 2cf435b1179..1887800fc38 100644
--- a/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.stderr
+++ b/tests/ui/pattern/deref-patterns/cant_move_out_of_pattern.stderr
@@ -32,6 +32,40 @@ help: consider borrowing the pattern binding
 LL |         deref!(ref x) => x,
    |                +++
 
-error: aborting due to 2 previous errors
+error[E0507]: cannot move out of a shared reference
+  --> $DIR/cant_move_out_of_pattern.rs:27:11
+   |
+LL |     match b {
+   |           ^
+LL |
+LL |         Container(x) => x,
+   |                   -
+   |                   |
+   |                   data moved here
+   |                   move occurs because `x` has type `Struct`, which does not implement the `Copy` trait
+   |
+help: consider borrowing the pattern binding
+   |
+LL |         Container(ref x) => x,
+   |                   +++
+
+error[E0507]: cannot move out of a shared reference
+  --> $DIR/cant_move_out_of_pattern.rs:35:11
+   |
+LL |     match rc {
+   |           ^^
+LL |
+LL |         Container(x) => x,
+   |                   -
+   |                   |
+   |                   data moved here
+   |                   move occurs because `x` has type `Struct`, which does not implement the `Copy` trait
+   |
+help: consider borrowing the pattern binding
+   |
+LL |         Container(ref x) => x,
+   |                   +++
+
+error: aborting due to 4 previous errors
 
 For more information about this error, try `rustc --explain E0507`.
diff --git a/tests/ui/pattern/deref-patterns/closure_capture.rs b/tests/ui/pattern/deref-patterns/closure_capture.rs
index fc0ddedac2b..08586b6c7ab 100644
--- a/tests/ui/pattern/deref-patterns/closure_capture.rs
+++ b/tests/ui/pattern/deref-patterns/closure_capture.rs
@@ -11,6 +11,15 @@ fn main() {
     assert_eq!(b.len(), 3);
     f();
 
+    let v = vec![1, 2, 3];
+    let f = || {
+        // this should count as a borrow of `v` as a whole
+        let [.., x] = v else { unreachable!() };
+        assert_eq!(x, 3);
+    };
+    assert_eq!(v, [1, 2, 3]);
+    f();
+
     let mut b = Box::new("aaa".to_string());
     let mut f = || {
         let deref!(ref mut s) = b else { unreachable!() };
@@ -18,4 +27,22 @@ fn main() {
     };
     f();
     assert_eq!(b.len(), 5);
+
+    let mut v = vec![1, 2, 3];
+    let mut f = || {
+        // this should count as a mutable borrow of `v` as a whole
+        let [.., ref mut x] = v else { unreachable!() };
+        *x = 4;
+    };
+    f();
+    assert_eq!(v, [1, 2, 4]);
+
+    let mut v = vec![1, 2, 3];
+    let mut f = || {
+        // here, `[.., x]` is adjusted by both an overloaded deref and a builtin deref
+        let [.., x] = &mut v else { unreachable!() };
+        *x = 4;
+    };
+    f();
+    assert_eq!(v, [1, 2, 4]);
 }
diff --git a/tests/ui/pattern/deref-patterns/fake_borrows.rs b/tests/ui/pattern/deref-patterns/fake_borrows.rs
index 35fa9cbf7d8..bf614d7d66f 100644
--- a/tests/ui/pattern/deref-patterns/fake_borrows.rs
+++ b/tests/ui/pattern/deref-patterns/fake_borrows.rs
@@ -11,4 +11,11 @@ fn main() {
         deref!(false) => {}
         _ => {},
     }
+    match b {
+        true => {}
+        _ if { *b = true; false } => {}
+        //~^ ERROR cannot assign `*b` in match guard
+        false => {}
+        _ => {},
+    }
 }
diff --git a/tests/ui/pattern/deref-patterns/fake_borrows.stderr b/tests/ui/pattern/deref-patterns/fake_borrows.stderr
index 6a591e6416c..8c060236d0d 100644
--- a/tests/ui/pattern/deref-patterns/fake_borrows.stderr
+++ b/tests/ui/pattern/deref-patterns/fake_borrows.stderr
@@ -7,6 +7,15 @@ LL |         deref!(true) => {}
 LL |         _ if { *b = true; false } => {}
    |                ^^^^^^^^^ cannot assign
 
-error: aborting due to 1 previous error
+error[E0510]: cannot assign `*b` in match guard
+  --> $DIR/fake_borrows.rs:16:16
+   |
+LL |     match b {
+   |           - value is immutable in match guard
+LL |         true => {}
+LL |         _ if { *b = true; false } => {}
+   |                ^^^^^^^^^ cannot assign
+
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0510`.
diff --git a/tests/ui/pattern/deref-patterns/implicit-const-deref.rs b/tests/ui/pattern/deref-patterns/implicit-const-deref.rs
new file mode 100644
index 00000000000..70f89629bc2
--- /dev/null
+++ b/tests/ui/pattern/deref-patterns/implicit-const-deref.rs
@@ -0,0 +1,19 @@
+//! Test that we get an error about structural equality rather than a type error when attempting to
+//! use const patterns of library pointer types. Currently there aren't any smart pointers that can
+//! be used in constant patterns, but we still need to make sure we don't implicitly dereference the
+//! scrutinee and end up with a type error; this would prevent us from reporting that only constants
+//! supporting structural equality can be used as patterns.
+#![feature(deref_patterns)]
+#![allow(incomplete_features)]
+
+const EMPTY: Vec<()> = Vec::new();
+
+fn main() {
+    // FIXME(inline_const_pat): if `inline_const_pat` is reinstated, there should be a case here for
+    // inline const block patterns as well; they're checked differently than named constants.
+    match vec![()] {
+        EMPTY => {}
+        //~^ ERROR: constant of non-structural type `Vec<()>` in a pattern
+        _ => {}
+    }
+}
diff --git a/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr b/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr
new file mode 100644
index 00000000000..21d09ec44c4
--- /dev/null
+++ b/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr
@@ -0,0 +1,16 @@
+error: constant of non-structural type `Vec<()>` in a pattern
+  --> $DIR/implicit-const-deref.rs:15:9
+   |
+LL | const EMPTY: Vec<()> = Vec::new();
+   | -------------------- constant defined here
+...
+LL |         EMPTY => {}
+   |         ^^^^^ constant of non-structural type
+  --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL
+   |
+   = note: `Vec<()>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
+   |
+   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
+
+error: aborting due to 1 previous error
+
diff --git a/tests/ui/pattern/deref-patterns/implicit-cow-deref.rs b/tests/ui/pattern/deref-patterns/implicit-cow-deref.rs
new file mode 100644
index 00000000000..a9b8de86010
--- /dev/null
+++ b/tests/ui/pattern/deref-patterns/implicit-cow-deref.rs
@@ -0,0 +1,45 @@
+//@ run-pass
+//! Test that implicit deref patterns interact as expected with `Cow` constructor patterns.
+#![feature(deref_patterns)]
+#![allow(incomplete_features)]
+
+use std::borrow::Cow;
+
+fn main() {
+    let cow: Cow<'static, [u8]> = Cow::Borrowed(&[1, 2, 3]);
+
+    match cow {
+        [..] => {}
+        _ => unreachable!(),
+    }
+
+    match cow {
+        Cow::Borrowed(_) => {}
+        Cow::Owned(_) => unreachable!(),
+    }
+
+    match Box::new(&cow) {
+        Cow::Borrowed { 0: _ } => {}
+        Cow::Owned { 0: _ } => unreachable!(),
+        _ => unreachable!(),
+    }
+
+    let cow_of_cow: Cow<'_, Cow<'static, [u8]>> = Cow::Owned(cow);
+
+    match cow_of_cow {
+        [..] => {}
+        _ => unreachable!(),
+    }
+
+    // This matches on the outer `Cow` (the owned one).
+    match cow_of_cow {
+        Cow::Borrowed(_) => unreachable!(),
+        Cow::Owned(_) => {}
+    }
+
+    match Box::new(&cow_of_cow) {
+        Cow::Borrowed { 0: _ } => unreachable!(),
+        Cow::Owned { 0: _ } => {}
+        _ => unreachable!(),
+    }
+}
diff --git a/tests/ui/pattern/deref-patterns/needs-gate.rs b/tests/ui/pattern/deref-patterns/needs-gate.rs
new file mode 100644
index 00000000000..2d5ec45217f
--- /dev/null
+++ b/tests/ui/pattern/deref-patterns/needs-gate.rs
@@ -0,0 +1,15 @@
+// gate-test-deref_patterns
+
+fn main() {
+    match Box::new(0) {
+        deref!(0) => {}
+        //~^ ERROR: use of unstable library feature `deref_patterns`: placeholder syntax for deref patterns
+        _ => {}
+    }
+
+    match Box::new(0) {
+        0 => {}
+        //~^ ERROR: mismatched types
+        _ => {}
+    }
+}
diff --git a/tests/ui/pattern/deref-patterns/needs-gate.stderr b/tests/ui/pattern/deref-patterns/needs-gate.stderr
new file mode 100644
index 00000000000..8687b5dc977
--- /dev/null
+++ b/tests/ui/pattern/deref-patterns/needs-gate.stderr
@@ -0,0 +1,29 @@
+error[E0658]: use of unstable library feature `deref_patterns`: placeholder syntax for deref patterns
+  --> $DIR/needs-gate.rs:5:9
+   |
+LL |         deref!(0) => {}
+   |         ^^^^^
+   |
+   = note: see issue #87121 <https://github.com/rust-lang/rust/issues/87121> for more information
+   = help: add `#![feature(deref_patterns)]` 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[E0308]: mismatched types
+  --> $DIR/needs-gate.rs:11:9
+   |
+LL |     match Box::new(0) {
+   |           ----------- this expression has type `Box<{integer}>`
+LL |         0 => {}
+   |         ^ expected `Box<{integer}>`, found integer
+   |
+   = note: expected struct `Box<{integer}>`
+                found type `{integer}`
+help: consider dereferencing to access the inner value using the Deref trait
+   |
+LL |     match *Box::new(0) {
+   |           +
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0308, E0658.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/tests/ui/pattern/deref-patterns/recursion-limit.rs b/tests/ui/pattern/deref-patterns/recursion-limit.rs
new file mode 100644
index 00000000000..c5fe520f6f1
--- /dev/null
+++ b/tests/ui/pattern/deref-patterns/recursion-limit.rs
@@ -0,0 +1,23 @@
+//! Test that implicit deref patterns respect the recursion limit
+#![feature(deref_patterns)]
+#![allow(incomplete_features)]
+#![recursion_limit = "8"]
+
+use std::ops::Deref;
+
+struct Cyclic;
+impl Deref for Cyclic {
+    type Target = Cyclic;
+    fn deref(&self) -> &Cyclic {
+        &Cyclic
+    }
+}
+
+fn main() {
+    match &Box::new(Cyclic) {
+        () => {}
+        //~^ ERROR: reached the recursion limit while auto-dereferencing `Cyclic`
+        //~| ERROR: the trait bound `Cyclic: DerefPure` is not satisfied
+        _ => {}
+    }
+}
diff --git a/tests/ui/pattern/deref-patterns/recursion-limit.stderr b/tests/ui/pattern/deref-patterns/recursion-limit.stderr
new file mode 100644
index 00000000000..9a83d1eb5a4
--- /dev/null
+++ b/tests/ui/pattern/deref-patterns/recursion-limit.stderr
@@ -0,0 +1,18 @@
+error[E0055]: reached the recursion limit while auto-dereferencing `Cyclic`
+  --> $DIR/recursion-limit.rs:18:9
+   |
+LL |         () => {}
+   |         ^^ deref recursion limit reached
+   |
+   = help: consider increasing the recursion limit by adding a `#![recursion_limit = "16"]` attribute to your crate (`recursion_limit`)
+
+error[E0277]: the trait bound `Cyclic: DerefPure` is not satisfied
+  --> $DIR/recursion-limit.rs:18:9
+   |
+LL |         () => {}
+   |         ^^ the trait `DerefPure` is not implemented for `Cyclic`
+
+error: aborting due to 2 previous errors
+
+Some errors have detailed explanations: E0055, E0277.
+For more information about an error, try `rustc --explain E0055`.
diff --git a/tests/ui/pattern/deref-patterns/ref-mut.rs b/tests/ui/pattern/deref-patterns/ref-mut.rs
index 1918008a761..43738671346 100644
--- a/tests/ui/pattern/deref-patterns/ref-mut.rs
+++ b/tests/ui/pattern/deref-patterns/ref-mut.rs
@@ -8,10 +8,19 @@ fn main() {
         deref!(x) => {}
         _ => {}
     }
+    match &mut vec![1] {
+        [x] => {}
+        _ => {}
+    }
 
     match &mut Rc::new(1) {
         deref!(x) => {}
         //~^ ERROR the trait bound `Rc<{integer}>: DerefMut` is not satisfied
         _ => {}
     }
+    match &mut Rc::new((1,)) {
+        (x,) => {}
+        //~^ ERROR the trait bound `Rc<({integer},)>: DerefMut` is not satisfied
+        _ => {}
+    }
 }
diff --git a/tests/ui/pattern/deref-patterns/ref-mut.stderr b/tests/ui/pattern/deref-patterns/ref-mut.stderr
index 41f1c3061ce..24a35b418e9 100644
--- a/tests/ui/pattern/deref-patterns/ref-mut.stderr
+++ b/tests/ui/pattern/deref-patterns/ref-mut.stderr
@@ -8,13 +8,19 @@ LL | #![feature(deref_patterns)]
    = note: `#[warn(incomplete_features)]` on by default
 
 error[E0277]: the trait bound `Rc<{integer}>: DerefMut` is not satisfied
-  --> $DIR/ref-mut.rs:13:9
+  --> $DIR/ref-mut.rs:17:9
    |
 LL |         deref!(x) => {}
    |         ^^^^^^^^^ the trait `DerefMut` is not implemented for `Rc<{integer}>`
    |
    = note: this error originates in the macro `deref` (in Nightly builds, run with -Z macro-backtrace for more info)
 
-error: aborting due to 1 previous error; 1 warning emitted
+error[E0277]: the trait bound `Rc<({integer},)>: DerefMut` is not satisfied
+  --> $DIR/ref-mut.rs:22:9
+   |
+LL |         (x,) => {}
+   |         ^^^^ the trait `DerefMut` is not implemented for `Rc<({integer},)>`
+
+error: aborting due to 2 previous errors; 1 warning emitted
 
 For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/pattern/deref-patterns/typeck.rs b/tests/ui/pattern/deref-patterns/typeck.rs
index f23f7042cd8..3a7ce9d1deb 100644
--- a/tests/ui/pattern/deref-patterns/typeck.rs
+++ b/tests/ui/pattern/deref-patterns/typeck.rs
@@ -10,26 +10,32 @@ fn main() {
     let vec: Vec<u32> = Vec::new();
     match vec {
         deref!([..]) => {}
+        [..] => {}
         _ => {}
     }
     match Box::new(true) {
         deref!(true) => {}
+        true => {}
         _ => {}
     }
     match &Box::new(true) {
         deref!(true) => {}
+        true => {}
         _ => {}
     }
     match &Rc::new(0) {
         deref!(1..) => {}
+        1.. => {}
         _ => {}
     }
     let _: &Struct = match &Rc::new(Struct) {
         deref!(x) => x,
+        Struct => &Struct,
         _ => unreachable!(),
     };
     let _: &[Struct] = match &Rc::new(vec![Struct]) {
         deref!(deref!(x)) => x,
+        [Struct] => &[Struct],
         _ => unreachable!(),
     };
 }
diff --git a/tests/ui/pattern/deref-patterns/typeck_fail.rs b/tests/ui/pattern/deref-patterns/typeck_fail.rs
index 040118449ec..4b9ad7d25f0 100644
--- a/tests/ui/pattern/deref-patterns/typeck_fail.rs
+++ b/tests/ui/pattern/deref-patterns/typeck_fail.rs
@@ -7,11 +7,22 @@ fn main() {
     match "foo".to_string() {
         deref!("foo") => {}
         //~^ ERROR: mismatched types
+        "foo" => {}
+        //~^ ERROR: mismatched types
         _ => {}
     }
     match &"foo".to_string() {
         deref!("foo") => {}
         //~^ ERROR: mismatched types
+        "foo" => {}
+        //~^ ERROR: mismatched types
+        _ => {}
+    }
+
+    // Make sure we don't try implicitly dereferncing any ADT.
+    match Some(0) {
+        Ok(0) => {}
+        //~^ ERROR: mismatched types
         _ => {}
     }
 }
diff --git a/tests/ui/pattern/deref-patterns/typeck_fail.stderr b/tests/ui/pattern/deref-patterns/typeck_fail.stderr
index 1c14802745a..3e2f3561882 100644
--- a/tests/ui/pattern/deref-patterns/typeck_fail.stderr
+++ b/tests/ui/pattern/deref-patterns/typeck_fail.stderr
@@ -7,13 +7,45 @@ LL |         deref!("foo") => {}
    |                ^^^^^ expected `str`, found `&str`
 
 error[E0308]: mismatched types
-  --> $DIR/typeck_fail.rs:13:16
+  --> $DIR/typeck_fail.rs:10:9
+   |
+LL |     match "foo".to_string() {
+   |           ----------------- this expression has type `String`
+...
+LL |         "foo" => {}
+   |         ^^^^^ expected `String`, found `&str`
+
+error[E0308]: mismatched types
+  --> $DIR/typeck_fail.rs:15:16
    |
 LL |     match &"foo".to_string() {
    |           ------------------ this expression has type `&String`
 LL |         deref!("foo") => {}
    |                ^^^^^ expected `str`, found `&str`
 
-error: aborting due to 2 previous errors
+error[E0308]: mismatched types
+  --> $DIR/typeck_fail.rs:17:9
+   |
+LL |     match &"foo".to_string() {
+   |           ------------------ this expression has type `&String`
+...
+LL |         "foo" => {}
+   |         ^^^^^ expected `&String`, found `&str`
+   |
+   = note: expected reference `&String`
+              found reference `&'static str`
+
+error[E0308]: mismatched types
+  --> $DIR/typeck_fail.rs:24:9
+   |
+LL |     match Some(0) {
+   |           ------- this expression has type `Option<{integer}>`
+LL |         Ok(0) => {}
+   |         ^^^^^ expected `Option<{integer}>`, found `Result<_, _>`
+   |
+   = note: expected enum `Option<{integer}>`
+              found enum `Result<_, _>`
+
+error: aborting due to 5 previous errors
 
 For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/pattern/deref-patterns/unsatisfied-bounds.rs b/tests/ui/pattern/deref-patterns/unsatisfied-bounds.rs
new file mode 100644
index 00000000000..00064b2320c
--- /dev/null
+++ b/tests/ui/pattern/deref-patterns/unsatisfied-bounds.rs
@@ -0,0 +1,21 @@
+#![feature(deref_patterns)]
+#![allow(incomplete_features)]
+
+struct MyPointer;
+
+impl std::ops::Deref for MyPointer {
+    type Target = ();
+    fn deref(&self) -> &() {
+        &()
+    }
+}
+
+fn main() {
+    // Test that we get a trait error if a user attempts implicit deref pats on their own impls.
+    // FIXME(deref_patterns): there should be a special diagnostic for missing `DerefPure`.
+    match MyPointer {
+        () => {}
+        //~^ the trait bound `MyPointer: DerefPure` is not satisfied
+        _ => {}
+    }
+}
diff --git a/tests/ui/pattern/deref-patterns/unsatisfied-bounds.stderr b/tests/ui/pattern/deref-patterns/unsatisfied-bounds.stderr
new file mode 100644
index 00000000000..983ce27865c
--- /dev/null
+++ b/tests/ui/pattern/deref-patterns/unsatisfied-bounds.stderr
@@ -0,0 +1,9 @@
+error[E0277]: the trait bound `MyPointer: DerefPure` is not satisfied
+  --> $DIR/unsatisfied-bounds.rs:17:9
+   |
+LL |         () => {}
+   |         ^^ the trait `DerefPure` is not implemented for `MyPointer`
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0277`.
diff --git a/tests/ui/pattern/non-structural-match-types-cycle-err.rs b/tests/ui/pattern/non-structural-match-types-cycle-err.rs
new file mode 100644
index 00000000000..a8e494c35b0
--- /dev/null
+++ b/tests/ui/pattern/non-structural-match-types-cycle-err.rs
@@ -0,0 +1,24 @@
+//@ edition:2021
+
+struct AnyOption<T>(T);
+impl<T> AnyOption<T> {
+    const NONE: Option<T> = None;
+}
+
+// This is an unfortunate side-effect of borrowchecking nested items
+// together with their parent. Evaluating the `AnyOption::<_>::NONE`
+// pattern for exhaustiveness checking relies on the layout of the
+// async block. This layout relies on `optimized_mir` of the nested
+// item which is now borrowck'd together with its parent. As
+// borrowck of the parent requires us to have already lowered the match,
+// this is a query cycle.
+
+fn uwu() {}
+fn defines() {
+    match Some(async {}) {
+        AnyOption::<_>::NONE => {}
+        //~^ ERROR cycle detected when building THIR for `defines`
+        _ => {}
+    }
+}
+fn main() {}
diff --git a/tests/ui/pattern/non-structural-match-types-cycle-err.stderr b/tests/ui/pattern/non-structural-match-types-cycle-err.stderr
new file mode 100644
index 00000000000..2f4ac63fc57
--- /dev/null
+++ b/tests/ui/pattern/non-structural-match-types-cycle-err.stderr
@@ -0,0 +1,64 @@
+error[E0391]: cycle detected when building THIR for `defines`
+  --> $DIR/non-structural-match-types-cycle-err.rs:19:9
+   |
+LL |         AnyOption::<_>::NONE => {}
+   |         ^^^^^^^^^^^^^^^^^^^^
+   |
+note: ...which requires evaluating type-level constant...
+  --> $DIR/non-structural-match-types-cycle-err.rs:5:5
+   |
+LL |     const NONE: Option<T> = None;
+   |     ^^^^^^^^^^^^^^^^^^^^^
+note: ...which requires const-evaluating + checking `<impl at $DIR/non-structural-match-types-cycle-err.rs:4:1: 4:21>::NONE`...
+  --> $DIR/non-structural-match-types-cycle-err.rs:5:5
+   |
+LL |     const NONE: Option<T> = None;
+   |     ^^^^^^^^^^^^^^^^^^^^^
+   = note: ...which requires computing layout of `core::option::Option<{async block@$DIR/non-structural-match-types-cycle-err.rs:18:16: 18:21}>`...
+   = note: ...which requires computing layout of `{async block@$DIR/non-structural-match-types-cycle-err.rs:18:16: 18:21}`...
+note: ...which requires optimizing MIR for `defines::{closure#0}`...
+  --> $DIR/non-structural-match-types-cycle-err.rs:18:16
+   |
+LL |     match Some(async {}) {
+   |                ^^^^^
+note: ...which requires elaborating drops for `defines::{closure#0}`...
+  --> $DIR/non-structural-match-types-cycle-err.rs:18:16
+   |
+LL |     match Some(async {}) {
+   |                ^^^^^
+note: ...which requires borrow-checking `defines`...
+  --> $DIR/non-structural-match-types-cycle-err.rs:17:1
+   |
+LL | fn defines() {
+   | ^^^^^^^^^^^^
+note: ...which requires promoting constants in MIR for `defines`...
+  --> $DIR/non-structural-match-types-cycle-err.rs:17:1
+   |
+LL | fn defines() {
+   | ^^^^^^^^^^^^
+note: ...which requires checking if `defines` contains FFI-unwind calls...
+  --> $DIR/non-structural-match-types-cycle-err.rs:17:1
+   |
+LL | fn defines() {
+   | ^^^^^^^^^^^^
+note: ...which requires building MIR for `defines`...
+  --> $DIR/non-structural-match-types-cycle-err.rs:17:1
+   |
+LL | fn defines() {
+   | ^^^^^^^^^^^^
+note: ...which requires match-checking `defines`...
+  --> $DIR/non-structural-match-types-cycle-err.rs:17:1
+   |
+LL | fn defines() {
+   | ^^^^^^^^^^^^
+   = note: ...which again requires building THIR for `defines`, completing the cycle
+note: cycle used when unsafety-checking `defines`
+  --> $DIR/non-structural-match-types-cycle-err.rs:17:1
+   |
+LL | fn defines() {
+   | ^^^^^^^^^^^^
+   = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information
+
+error: aborting due to 1 previous error
+
+For more information about this error, try `rustc --explain E0391`.
diff --git a/tests/ui/pattern/non-structural-match-types.rs b/tests/ui/pattern/non-structural-match-types.rs
index 5869767c936..a5ff7fcdb5e 100644
--- a/tests/ui/pattern/non-structural-match-types.rs
+++ b/tests/ui/pattern/non-structural-match-types.rs
@@ -1,6 +1,4 @@
 //@ edition:2021
-#![feature(const_async_blocks)]
-
 struct AnyOption<T>(T);
 impl<T> AnyOption<T> {
     const NONE: Option<T> = None;
@@ -19,11 +17,5 @@ fn defines() {
         //~^ ERROR constant of non-structural type
         _ => {}
     }
-
-    match Some(async {}) {
-        AnyOption::<_>::NONE => {}
-        //~^ ERROR constant of non-structural type
-        _ => {}
-    }
 }
 fn main() {}
diff --git a/tests/ui/pattern/non-structural-match-types.stderr b/tests/ui/pattern/non-structural-match-types.stderr
index da675a9f3ff..3b74ffe7cb7 100644
--- a/tests/ui/pattern/non-structural-match-types.stderr
+++ b/tests/ui/pattern/non-structural-match-types.stderr
@@ -1,5 +1,5 @@
 error: constant of non-structural type `Option<fn() {uwu}>` in a pattern
-  --> $DIR/non-structural-match-types.rs:12:9
+  --> $DIR/non-structural-match-types.rs:10:9
    |
 LL | impl<T> AnyOption<T> {
    | --------------------
@@ -11,8 +11,8 @@ LL |         AnyOption::<_>::NONE => {}
    |
    = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
 
-error: constant of non-structural type `Option<{closure@$DIR/non-structural-match-types.rs:17:16: 17:18}>` in a pattern
-  --> $DIR/non-structural-match-types.rs:18:9
+error: constant of non-structural type `Option<{closure@$DIR/non-structural-match-types.rs:15:16: 15:18}>` in a pattern
+  --> $DIR/non-structural-match-types.rs:16:9
    |
 LL | impl<T> AnyOption<T> {
    | --------------------
@@ -24,19 +24,5 @@ LL |         AnyOption::<_>::NONE => {}
    |
    = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
 
-error: constant of non-structural type `Option<{async block@$DIR/non-structural-match-types.rs:23:16: 23:21}>` in a pattern
-  --> $DIR/non-structural-match-types.rs:24:9
-   |
-LL | impl<T> AnyOption<T> {
-   | --------------------
-LL |     const NONE: Option<T> = None;
-   |     --------------------- constant defined here
-...
-LL |         AnyOption::<_>::NONE => {}
-   |         ^^^^^^^^^^^^^^^^^^^^ constant of non-structural type
-   |
-   = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralPartialEq.html for details
-   = note: `ResumeTy` must be annotated with `#[derive(PartialEq)]` to be usable in patterns
-
-error: aborting due to 3 previous errors
+error: aborting due to 2 previous errors
 
diff --git a/tests/ui/pattern/patkind-ref-binding-issue-114896.fixed b/tests/ui/pattern/patkind-ref-binding-issue-114896.fixed
index 086a119eb77..2eeca4bdb7a 100644
--- a/tests/ui/pattern/patkind-ref-binding-issue-114896.fixed
+++ b/tests/ui/pattern/patkind-ref-binding-issue-114896.fixed
@@ -5,6 +5,6 @@ fn main() {
     fn x(a: &char) {
         let &(mut b) = a;
         b.make_ascii_uppercase();
-//~^ cannot borrow `b` as mutable, as it is not declared as mutable
+        //~^ ERROR cannot borrow `b` as mutable, as it is not declared as mutable
     }
 }
diff --git a/tests/ui/pattern/patkind-ref-binding-issue-114896.rs b/tests/ui/pattern/patkind-ref-binding-issue-114896.rs
index b4d6b72c01f..f074246b782 100644
--- a/tests/ui/pattern/patkind-ref-binding-issue-114896.rs
+++ b/tests/ui/pattern/patkind-ref-binding-issue-114896.rs
@@ -5,6 +5,6 @@ fn main() {
     fn x(a: &char) {
         let &b = a;
         b.make_ascii_uppercase();
-//~^ cannot borrow `b` as mutable, as it is not declared as mutable
+        //~^ ERROR cannot borrow `b` as mutable, as it is not declared as mutable
     }
 }
diff --git a/tests/ui/pattern/rest-pat-syntactic.rs b/tests/ui/pattern/rest-pat-syntactic.rs
index 1de29e69b05..59c687bb5a8 100644
--- a/tests/ui/pattern/rest-pat-syntactic.rs
+++ b/tests/ui/pattern/rest-pat-syntactic.rs
@@ -11,7 +11,7 @@ macro_rules! accept_pat {
 
 accept_pat!(..);
 
-#[cfg(FALSE)]
+#[cfg(false)]
 fn rest_patterns() {
     // Top level:
     fn foo(..: u8) {}
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs
index 621ca7cc792..c171dcf0ca6 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs
@@ -13,14 +13,14 @@
 /// to fail in HIR typeck on stable. As such, they need to be separate from the other tests.
 fn errors_caught_in_hir_typeck_on_stable() {
     let [&x] = &[&mut 0];
-    //[stable2021]~^ mismatched types
+    //[stable2021]~^ ERROR mismatched types
     //[stable2021]~| types differ in mutability
     //[classic2024]~^^^ ERROR: cannot move out of type
     #[cfg(any(classic2021, structural2021))] let _: u32 = x;
     #[cfg(structural2024)] let _: &u32 = x;
 
     let [&x] = &mut [&mut 0];
-    //[stable2021]~^ mismatched types
+    //[stable2021]~^ ERROR mismatched types
     //[stable2021]~| types differ in mutability
     //[classic2024]~^^^ ERROR: cannot move out of type
     #[cfg(any(classic2021, structural2021))] let _: u32 = x;
@@ -34,7 +34,7 @@ pub fn main() {
     }
 
     let &ref mut x = &0;
-    //~^ cannot borrow data in a `&` reference as mutable [E0596]
+    //~^ ERROR cannot borrow data in a `&` reference as mutable [E0596]
 
     // For 2021 edition, this is also a regression test for #136223
     // since the maximum mutability is downgraded during the pattern check process.
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.rs
index c8e988ad76d..94691e77bd8 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.rs
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/mut-ref-mut.rs
@@ -28,6 +28,6 @@ pub fn main() {
     let [&mut mut x] = &[&mut 0];
     //[classic2024]~^ ERROR: mismatched types
     //[classic2024]~| cannot match inherited `&` with `&mut` pattern
-    //[structural2024]~^^^ binding cannot be both mutable and by-reference
+    //[structural2024]~^^^ ERROR binding cannot be both mutable and by-reference
     #[cfg(any(stable2021, classic2021, structural2021))] { x = 0 }
 }
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.rs
index 62c1c28022b..877b10dcfd5 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.rs
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.rs
@@ -30,63 +30,63 @@ pub fn main() {
         #[cfg(any(classic2024, structural2024))] let _: &u32 = x;
     }
     if let Some(Some(&&x)) = &Some(Some(&0)) {
-        //[stable2021,classic2021,structural2021]~^ mismatched types
+        //[stable2021,classic2021,structural2021]~^ ERROR mismatched types
         //[stable2021,classic2021,structural2021]~| expected integer, found `&_`
         #[cfg(any(classic2024, structural2024))] let _: u32 = x;
     }
 
     // Tests for eating a lone inherited reference
     if let Some(Some(&x)) = &Some(&Some(0)) {
-        //[stable2021]~^ mismatched types
+        //[stable2021]~^ ERROR mismatched types
         //[stable2021]~| expected integer, found `&_`
         #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x;
     }
     if let Some(&Some(x)) = &Some(Some(0)) {
-        //[stable2021]~^ mismatched types
+        //[stable2021]~^ ERROR mismatched types
         //[stable2021]~| expected `Option<{integer}>`, found `&_`
         #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x;
     }
     if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) {
-        //[stable2021]~^ mismatched types
+        //[stable2021]~^ ERROR mismatched types
         //[stable2021]~| expected integer, found `&mut _`
         #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x;
     }
 
     // Tests for `&` patterns matching real `&mut` reference types
     if let Some(&Some(&x)) = Some(&Some(&mut 0)) {
-        //[stable2021]~^ mismatched types
+        //[stable2021]~^ ERROR mismatched types
         //[stable2021]~| types differ in mutability
         #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x;
     }
 
     // Tests for eating only one layer and also eating a lone inherited reference
     if let Some(&Some(&x)) = &Some(&Some(0)) {
-        //[stable2021,classic2021,structural2021]~^ mismatched types
+        //[stable2021,classic2021,structural2021]~^ ERROR mismatched types
         //[stable2021,classic2021,structural2021]~| expected integer, found `&_`
         #[cfg(any(classic2024, structural2024))] let _: u32 = x;
     }
 
     // Tests for `&` matching a lone inherited possibly-`&mut` reference
     if let Some(&Some(Some(&x))) = &Some(Some(&mut Some(0))) {
-        //[stable2021]~^ mismatched types
+        //[stable2021]~^ ERROR mismatched types
         //[stable2021]~| expected `Option<&mut Option<{integer}>>`, found `&_`
         #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x;
     }
     if let Some(&Some(x)) = &mut Some(Some(0)) {
-        //[stable2021]~^ mismatched types
+        //[stable2021]~^ ERROR mismatched types
         //[stable2021]~| expected `Option<{integer}>`, found `&_`
         #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x;
     }
 
     // Tests eating one layer, eating a lone inherited ref, and `&` eating `&mut` (realness varies)
     if let Some(&Some(&x)) = &Some(&mut Some(0)) {
-        //[stable2021,classic2021,structural2021]~^ mismatched types
+        //[stable2021,classic2021,structural2021]~^ ERROR mismatched types
         //[stable2021]~| types differ in mutability
         //[classic2021,structural2021]~| expected integer, found `&_`
         #[cfg(any(classic2024, structural2024))] let _: u32 = x;
     }
     if let Some(&Some(&x)) = &mut Some(&Some(0)) {
-        //[stable2021,classic2021,structural2021]~^ mismatched types
+        //[stable2021,classic2021,structural2021]~^ ERROR mismatched types
         //[stable2021,classic2021,structural2021]~| expected integer, found `&_`
         #[cfg(any(classic2024, structural2024))] let _: u32 = x;
     }
@@ -94,46 +94,46 @@ pub fn main() {
     // Tests for eat-inner and eat-both rulesets matching on the outer reference if matching on the
     // inner reference causes a mutability mismatch. i.e. tests for "fallback-to-outer" deref rules.
     let [&mut x] = &mut [&0];
-    //[stable2021]~^ mismatched types
+    //[stable2021]~^ ERROR mismatched types
     //[stable2021]~| types differ in mutability
     #[cfg(any(classic2021, structural2021))] let _: u32 = x;
     #[cfg(any(classic2024, structural2024))] let _: &u32 = x;
 
     let [&mut ref x] = &mut [&0];
-    //[stable2021]~^ mismatched types
+    //[stable2021]~^ ERROR mismatched types
     //[stable2021]~| types differ in mutability
     #[cfg(any(classic2021, structural2021))] let _: &u32 = x;
     #[cfg(any(classic2024, structural2024))] let _: &&u32 = x;
 
     fn borrowck_error_on_structural2021() {
         let [&mut ref mut x] = &mut [&0];
-        //[stable2021]~^ mismatched types
+        //[stable2021]~^ ERROR mismatched types
         //[stable2021]~| types differ in mutability
-        //[classic2021,structural2021]~^^^ cannot borrow data in a `&` reference as mutable
+        //[classic2021,structural2021]~^^^ ERROR cannot borrow data in a `&` reference as mutable
         #[cfg(any(classic2024, structural2024))] let _: &mut &u32 = x;
     }
     borrowck_error_on_structural2021();
 
     let [&mut mut x] = &mut [&0];
-    //[stable2021]~^ mismatched types
+    //[stable2021]~^ ERROR mismatched types
     //[stable2021]~| types differ in mutability
     #[cfg(any(classic2021, structural2021))] let _: u32 = x;
     #[cfg(any(classic2024, structural2024))] let _: &u32 = x;
 
     let [&mut &x] = &mut [&0];
-    //[stable2021,classic2021,structural2021]~^ mismatched types
+    //[stable2021,classic2021,structural2021]~^ ERROR mismatched types
     //[stable2021]~| types differ in mutability
     //[classic2021,structural2021]~| expected integer, found `&_`
     #[cfg(any(classic2024, structural2024))] let _: u32 = x;
 
     let [&mut &ref x] = &mut [&0];
-    //[stable2021,classic2021,structural2021]~^ mismatched types
+    //[stable2021,classic2021,structural2021]~^ ERROR mismatched types
     //[stable2021]~| types differ in mutability
     //[classic2021,structural2021]~| expected integer, found `&_`
     #[cfg(any(classic2024, structural2024))] let _: &u32 = x;
 
     let [&mut &(mut x)] = &mut [&0];
-    //[stable2021,classic2021,structural2021]~^ mismatched types
+    //[stable2021,classic2021,structural2021]~^ ERROR mismatched types
     //[stable2021]~| types differ in mutability
     //[classic2021,structural2021]~| expected integer, found `&_`
     #[cfg(any(classic2024, structural2024))] let _: u32 = x;
diff --git a/tests/ui/pattern/usefulness/doc-hidden-fields.rs b/tests/ui/pattern/usefulness/doc-hidden-fields.rs
index 549e0d1af55..a3c3740b34a 100644
--- a/tests/ui/pattern/usefulness/doc-hidden-fields.rs
+++ b/tests/ui/pattern/usefulness/doc-hidden-fields.rs
@@ -13,14 +13,14 @@ struct InCrate {
 
 fn main() {
     let HiddenStruct { one, two } = HiddenStruct::default();
-    //~^ pattern requires `..` due to inaccessible fields
+    //~^ ERROR pattern requires `..` due to inaccessible fields
 
     let HiddenStruct { one } = HiddenStruct::default();
-    //~^ pattern does not mention field `two` and inaccessible fields
+    //~^ ERROR pattern does not mention field `two` and inaccessible fields
 
     let HiddenStruct { one, hide } = HiddenStruct::default();
-    //~^ pattern does not mention field `two`
+    //~^ ERROR pattern does not mention field `two`
 
     let InCrate { a, b } = InCrate { a: 0, b: false, im_hidden: 0 };
-    //~^ pattern does not mention field `im_hidden`
+    //~^ ERROR pattern does not mention field `im_hidden`
 }
diff --git a/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs b/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs
index 56842917f50..4bbdc7b139f 100644
--- a/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs
+++ b/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.rs
@@ -16,28 +16,28 @@ fn main() {
         HiddenEnum::A => {}
         HiddenEnum::B => {}
     }
-    //~^^^^ non-exhaustive patterns: `_` not covered
+    //~^^^^ ERROR non-exhaustive patterns: `_` not covered
 
     match HiddenEnum::A {
         HiddenEnum::A => {}
         HiddenEnum::C => {}
     }
-    //~^^^^ non-exhaustive patterns: `HiddenEnum::B` not covered
+    //~^^^^ ERROR non-exhaustive patterns: `HiddenEnum::B` not covered
 
     match HiddenEnum::A {
         HiddenEnum::A => {}
     }
-    //~^^^ non-exhaustive patterns: `HiddenEnum::B` and `_` not covered
+    //~^^^ ERROR non-exhaustive patterns: `HiddenEnum::B` and `_` not covered
 
     match None {
         None => {}
         Some(HiddenEnum::A) => {}
     }
-    //~^^^^ non-exhaustive patterns: `Some(HiddenEnum::B)` and `Some(_)` not covered
+    //~^^^^ ERROR non-exhaustive patterns: `Some(HiddenEnum::B)` and `Some(_)` not covered
 
     match InCrate::A {
         InCrate::A => {}
         InCrate::B => {}
     }
-    //~^^^^ non-exhaustive patterns: `InCrate::C` not covered
+    //~^^^^ ERROR non-exhaustive patterns: `InCrate::C` not covered
 }
diff --git a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs
index d0a8a10f2f3..4a7b2c956fc 100644
--- a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs
+++ b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.rs
@@ -24,12 +24,12 @@ enum E {
     //~| NOTE  not covered
     //~| NOTE  not covered
     C
-    //~^ not covered
-    //~| not covered
-    //~| not covered
-    //~| not covered
-    //~| not covered
-    //~| not covered
+    //~^ NOTE not covered
+    //~| NOTE not covered
+    //~| NOTE not covered
+    //~| NOTE not covered
+    //~| NOTE not covered
+    //~| NOTE not covered
 }
 
 fn by_val(e: E) {
@@ -42,7 +42,7 @@ fn by_val(e: E) {
 
     let E::A = e;
     //~^ ERROR refutable pattern in local binding
-    //~| patterns `E::B` and `E::C` not covered
+    //~| NOTE patterns `E::B` and `E::C` not covered
     //~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
     //~| NOTE for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
     //~| NOTE the matched value is of type `E`
@@ -51,14 +51,14 @@ fn by_val(e: E) {
 fn by_ref_once(e: &E) {
     match e {
     //~^ ERROR non-exhaustive patterns
-    //~| patterns `&E::B` and `&E::C` not covered
+    //~| NOTE patterns `&E::B` and `&E::C` not covered
     //~| NOTE the matched value is of type `&E`
         E::A => {}
     }
 
     let E::A = e;
     //~^ ERROR refutable pattern in local binding
-    //~| patterns `&E::B` and `&E::C` not covered
+    //~| NOTE patterns `&E::B` and `&E::C` not covered
     //~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
     //~| NOTE for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
     //~| NOTE the matched value is of type `&E`
@@ -67,14 +67,14 @@ fn by_ref_once(e: &E) {
 fn by_ref_thrice(e: & &mut &E) {
     match e {
     //~^ ERROR non-exhaustive patterns
-    //~| patterns `&&mut &E::B` and `&&mut &E::C` not covered
+    //~| NOTE patterns `&&mut &E::B` and `&&mut &E::C` not covered
     //~| NOTE the matched value is of type `&&mut &E`
         E::A => {}
     }
 
     let E::A = e;
     //~^ ERROR refutable pattern in local binding
-    //~| patterns `&&mut &E::B` and `&&mut &E::C` not covered
+    //~| NOTE patterns `&&mut &E::B` and `&&mut &E::C` not covered
     //~| NOTE `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with
     //~| NOTE for more information, visit https://doc.rust-lang.org/book/ch19-02-refutability.html
     //~| NOTE the matched value is of type `&&mut &E`
@@ -93,7 +93,7 @@ enum Opt {
 fn ref_pat(e: Opt) {
     match e {
         //~^ ERROR non-exhaustive patterns
-        //~| pattern `Opt::None` not covered
+        //~| NOTE pattern `Opt::None` not covered
         //~| NOTE the matched value is of type `Opt`
         Opt::Some(ref _x) => {}
     }
diff --git a/tests/ui/pattern/usefulness/stable-gated-fields.rs b/tests/ui/pattern/usefulness/stable-gated-fields.rs
index 61b202b77f6..7be2722daac 100644
--- a/tests/ui/pattern/usefulness/stable-gated-fields.rs
+++ b/tests/ui/pattern/usefulness/stable-gated-fields.rs
@@ -6,10 +6,10 @@ use unstable::UnstableStruct;
 
 fn main() {
     let UnstableStruct { stable } = UnstableStruct::default();
-    //~^ pattern does not mention field `stable2` and inaccessible fields
+    //~^ ERROR pattern does not mention field `stable2` and inaccessible fields
 
     let UnstableStruct { stable, stable2 } = UnstableStruct::default();
-    //~^ pattern requires `..` due to inaccessible fields
+    //~^ ERROR pattern requires `..` due to inaccessible fields
 
     // OK: stable field is matched
     let UnstableStruct { stable, stable2, .. } = UnstableStruct::default();
diff --git a/tests/ui/pattern/usefulness/stable-gated-patterns.rs b/tests/ui/pattern/usefulness/stable-gated-patterns.rs
index 5ceffbf0923..d5848344154 100644
--- a/tests/ui/pattern/usefulness/stable-gated-patterns.rs
+++ b/tests/ui/pattern/usefulness/stable-gated-patterns.rs
@@ -8,11 +8,11 @@ fn main() {
     match UnstableEnum::Stable {
         UnstableEnum::Stable => {}
     }
-    //~^^^ non-exhaustive patterns: `UnstableEnum::Stable2` and `_` not covered
+    //~^^^ ERROR non-exhaustive patterns: `UnstableEnum::Stable2` and `_` not covered
 
     match UnstableEnum::Stable {
         UnstableEnum::Stable => {}
         UnstableEnum::Stable2 => {}
     }
-    //~^^^^ non-exhaustive patterns: `_` not covered
+    //~^^^^ ERROR non-exhaustive patterns: `_` not covered
 }
diff --git a/tests/ui/pattern/usefulness/unstable-gated-fields.rs b/tests/ui/pattern/usefulness/unstable-gated-fields.rs
index e6a4494867a..08b46283f65 100644
--- a/tests/ui/pattern/usefulness/unstable-gated-fields.rs
+++ b/tests/ui/pattern/usefulness/unstable-gated-fields.rs
@@ -8,10 +8,10 @@ use unstable::UnstableStruct;
 
 fn main() {
     let UnstableStruct { stable, stable2, } = UnstableStruct::default();
-    //~^ pattern does not mention field `unstable`
+    //~^ ERROR pattern does not mention field `unstable`
 
     let UnstableStruct { stable, unstable, } = UnstableStruct::default();
-    //~^ pattern does not mention field `stable2`
+    //~^ ERROR pattern does not mention field `stable2`
 
     // OK: stable field is matched
     let UnstableStruct { stable, stable2, unstable } = UnstableStruct::default();
diff --git a/tests/ui/pattern/usefulness/unstable-gated-patterns.rs b/tests/ui/pattern/usefulness/unstable-gated-patterns.rs
index e6db495a149..3acc0738bbc 100644
--- a/tests/ui/pattern/usefulness/unstable-gated-patterns.rs
+++ b/tests/ui/pattern/usefulness/unstable-gated-patterns.rs
@@ -11,7 +11,7 @@ fn main() {
         UnstableEnum::Stable => {}
         UnstableEnum::Stable2 => {}
     }
-    //~^^^^ non-exhaustive patterns: `UnstableEnum::Unstable` not covered
+    //~^^^^ ERROR non-exhaustive patterns: `UnstableEnum::Unstable` not covered
 
     // Ok: all variants are explicitly matched
     match UnstableEnum::Stable {