about summary refs log tree commit diff
diff options
context:
space:
mode:
authordianne <diannes.gm@gmail.com>2025-01-25 23:32:12 -0800
committerdianne <diannes.gm@gmail.com>2025-02-18 17:44:28 -0800
commit8dc64a405d53f30fef4a080afb68d10e59318a3d (patch)
treec626024c3cfc795df34b1f1c1e85e62989086c96
parent3e77657312dbd7da6a398825860b01e838893b3c (diff)
downloadrust-8dc64a405d53f30fef4a080afb68d10e59318a3d.tar.gz
rust-8dc64a405d53f30fef4a080afb68d10e59318a3d.zip
"classic2021" and "structural2021" rulesets: add eat-inherited-ref-alone deref rules
-rw-r--r--compiler/rustc_hir_typeck/src/pat.rs39
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2021.stderr167
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2024.stderr10
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.rs54
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.stable2021.stderr38
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2021.stderr154
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2024.stderr30
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2021.stderr18
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.fixed4
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.stderr2
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.rs4
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.stable2021.stderr2
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2021.stderr18
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.fixed4
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.stderr2
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr72
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.rs26
-rw-r--r--tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr72
18 files changed, 195 insertions, 521 deletions
diff --git a/compiler/rustc_hir_typeck/src/pat.rs b/compiler/rustc_hir_typeck/src/pat.rs
index ae00bb4e218..47175cda63b 100644
--- a/compiler/rustc_hir_typeck/src/pat.rs
+++ b/compiler/rustc_hir_typeck/src/pat.rs
@@ -230,10 +230,12 @@ enum InheritedRefMatchRule {
     /// underlying type is not a reference type, the inherited reference will be consumed.
     EatInner,
     /// When the underlying type is a reference type, reference patterns consume both layers of
-    /// reference, i.e. they both reset the binding mode and consume the reference type. Reference
-    /// patterns are not permitted when there is no underlying reference type, i.e. they can't eat
-    /// only an inherited reference. This is the current stable Rust behavior.
-    EatBoth,
+    /// reference, i.e. they both reset the binding mode and consume the reference type.
+    EatBoth {
+        /// Whether to allow reference patterns to consume only an inherited reference when matching
+        /// against a non-reference type. This is `false` for stable Rust.
+        eat_inherited_ref_alone: bool,
+    },
 }
 
 impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
@@ -259,10 +261,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
             } else {
                 // Currently, matching against an inherited ref on edition 2024 is an error.
                 // Use `EatBoth` as a fallback to be similar to stable Rust.
-                InheritedRefMatchRule::EatBoth
+                InheritedRefMatchRule::EatBoth { eat_inherited_ref_alone: false }
             }
         } else {
-            InheritedRefMatchRule::EatBoth
+            InheritedRefMatchRule::EatBoth {
+                eat_inherited_ref_alone: self.tcx.features().ref_pat_eat_one_layer_2024()
+                    || self.tcx.features().ref_pat_eat_one_layer_2024_structural(),
+            }
         }
     }
 
@@ -2381,9 +2386,29 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
                         return expected;
                     }
                 }
-                InheritedRefMatchRule::EatBoth => {
+                InheritedRefMatchRule::EatBoth { eat_inherited_ref_alone: true } => {
                     // Reset binding mode on old editions
                     pat_info.binding_mode = ByRef::No;
+
+                    if let ty::Ref(_, _, _) = *expected.kind() {
+                        // Consume both the inherited and inner references.
+                    } else {
+                        // The expected type isn't a reference type, so only match against the
+                        // inherited reference.
+                        if pat_mutbl > inh_mut {
+                            // We can't match a lone inherited shared reference with `&mut`.
+                            self.error_inherited_ref_mutability_mismatch(pat, pat_prefix_span);
+                        }
+
+                        self.typeck_results.borrow_mut().skipped_ref_pats_mut().insert(pat.hir_id);
+                        self.check_pat(inner, expected, pat_info);
+                        return expected;
+                    }
+                }
+                InheritedRefMatchRule::EatBoth { eat_inherited_ref_alone: false } => {
+                    // Reset binding mode on stable Rust. This will be a type error below if
+                    // `expected` is not a reference type.
+                    pat_info.binding_mode = ByRef::No;
                     self.add_rust_2024_migration_desugared_pat(
                         pat_info.top_info.hir_id,
                         pat,
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2021.stderr
index e039884cdb1..a856a0eaf2a 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2021.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2021.stderr
@@ -58,155 +58,20 @@ LL |     if let Some(&Some(&mut _)) = &mut Some(&Some(0)) {
            found mutable reference `&mut _`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:50:17
-   |
-LL |     if let Some(&Some(Some(&mut x))) = &Some(Some(&mut Some(0))) {
-   |                 ^^^^^^^^^^^^^^^^^^^    ------------------------- this expression has type `&Option<Option<&mut Option<{integer}>>>`
-   |                 |
-   |                 expected `Option<&mut Option<{integer}>>`, found `&_`
-   |
-   = note:   expected enum `Option<&mut Option<{integer}>>`
-           found reference `&_`
-
-error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:57:17
+  --> $DIR/pattern-errors.rs:56:17
    |
 LL |     if let Some(&mut Some(x)) = &Some(Some(0)) {
-   |                 ^^^^^^^^^^^^    -------------- this expression has type `&Option<Option<{integer}>>`
-   |                 |
-   |                 expected `Option<{integer}>`, found `&mut _`
-   |
-   = note:           expected enum `Option<{integer}>`
-           found mutable reference `&mut _`
-
-error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:66:11
-   |
-LL |     let &[&mut x] = &&mut [0];
-   |           ^^^^^^    --------- this expression has type `&&mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
-   |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:66:11
-   |
-LL |     let &[&mut x] = &&mut [0];
-   |           ^^^^^^
-help: consider removing `&mut` from the pattern
-   |
-LL -     let &[&mut x] = &&mut [0];
-LL +     let &[x] = &&mut [0];
-   |
-
-error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:73:11
-   |
-LL |     let &[&mut x] = &mut &mut [0];
-   |           ^^^^^^    ------------- this expression has type `&mut &mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
-   |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:73:11
-   |
-LL |     let &[&mut x] = &mut &mut [0];
-   |           ^^^^^^
-help: consider removing `&mut` from the pattern
-   |
-LL -     let &[&mut x] = &mut &mut [0];
-LL +     let &[x] = &mut &mut [0];
-   |
-
-error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:80:11
-   |
-LL |     let &[&mut ref x] = &&mut [0];
-   |           ^^^^^^^^^^    --------- this expression has type `&&mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
-   |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:80:11
-   |
-LL |     let &[&mut ref x] = &&mut [0];
-   |           ^^^^^^^^^^
-help: consider removing `&mut` from the pattern
-   |
-LL -     let &[&mut ref x] = &&mut [0];
-LL +     let &[ref x] = &&mut [0];
-   |
-
-error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:87:11
-   |
-LL |     let &[&mut ref x] = &mut &mut [0];
-   |           ^^^^^^^^^^    ------------- this expression has type `&mut &mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
-   |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:87:11
-   |
-LL |     let &[&mut ref x] = &mut &mut [0];
-   |           ^^^^^^^^^^
-help: consider removing `&mut` from the pattern
-   |
-LL -     let &[&mut ref x] = &mut &mut [0];
-LL +     let &[ref x] = &mut &mut [0];
-   |
-
-error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:94:11
+   |                 ^^^^^
    |
-LL |     let &[&mut mut x] = &&mut [0];
-   |           ^^^^^^^^^^    --------- this expression has type `&&mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
-   |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:94:11
-   |
-LL |     let &[&mut mut x] = &&mut [0];
-   |           ^^^^^^^^^^
-help: consider removing `&mut` from the pattern
-   |
-LL -     let &[&mut mut x] = &&mut [0];
-LL +     let &[mut x] = &&mut [0];
-   |
-
-error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:101:11
-   |
-LL |     let &[&mut mut x] = &mut &mut [0];
-   |           ^^^^^^^^^^    ------------- this expression has type `&mut &mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
-   |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:101:11
-   |
-LL |     let &[&mut mut x] = &mut &mut [0];
-   |           ^^^^^^^^^^
-help: consider removing `&mut` from the pattern
+   = note: cannot match inherited `&` with `&mut` pattern
+help: replace this `&mut` pattern with `&`
    |
-LL -     let &[&mut mut x] = &mut &mut [0];
-LL +     let &[mut x] = &mut &mut [0];
+LL -     if let Some(&mut Some(x)) = &Some(Some(0)) {
+LL +     if let Some(&Some(x)) = &Some(Some(0)) {
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:122:11
+  --> $DIR/pattern-errors.rs:114:11
    |
 LL |     let [&&mut x] = &[&mut 0];
    |           ^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -222,7 +87,7 @@ LL +     let [&x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:129:11
+  --> $DIR/pattern-errors.rs:121:11
    |
 LL |     let [&&mut x] = &mut [&mut 0];
    |           ^^^^^^    ------------- this expression has type `&mut [&mut {integer}; 1]`
@@ -238,7 +103,7 @@ LL +     let [&x] = &mut [&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:136:11
+  --> $DIR/pattern-errors.rs:128:11
    |
 LL |     let [&&mut ref x] = &[&mut 0];
    |           ^^^^^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -254,7 +119,7 @@ LL +     let [&ref x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:143:11
+  --> $DIR/pattern-errors.rs:135:11
    |
 LL |     let [&&mut ref x] = &mut [&mut 0];
    |           ^^^^^^^^^^    ------------- this expression has type `&mut [&mut {integer}; 1]`
@@ -270,7 +135,7 @@ LL +     let [&ref x] = &mut [&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:150:11
+  --> $DIR/pattern-errors.rs:142:11
    |
 LL |     let [&&mut mut x] = &[&mut 0];
    |           ^^^^^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -286,7 +151,7 @@ LL +     let [&mut x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:157:11
+  --> $DIR/pattern-errors.rs:149:11
    |
 LL |     let [&&mut mut x] = &mut [&mut 0];
    |           ^^^^^^^^^^    ------------- this expression has type `&mut [&mut {integer}; 1]`
@@ -302,7 +167,7 @@ LL +     let [&mut x] = &mut [&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:172:15
+  --> $DIR/pattern-errors.rs:164:15
    |
 LL |     let [&mut &x] = &[&mut 0];
    |               ^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -318,7 +183,7 @@ LL +     let [&mut x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:178:15
+  --> $DIR/pattern-errors.rs:170:15
    |
 LL |     let [&mut &ref x] = &[&mut 0];
    |               ^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -334,7 +199,7 @@ LL +     let [&mut ref x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:184:15
+  --> $DIR/pattern-errors.rs:176:15
    |
 LL |     let [&mut &(mut x)] = &[&mut 0];
    |               ^^^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -349,6 +214,6 @@ LL -     let [&mut &(mut x)] = &[&mut 0];
 LL +     let [&mut mut x)] = &[&mut 0];
    |
 
-error: aborting due to 21 previous errors
+error: aborting due to 14 previous errors
 
 For more information about this error, try `rustc --explain E0308`.
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2024.stderr
index b98cfe337ef..90510d23e66 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2024.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.classic2024.stderr
@@ -64,7 +64,7 @@ LL +     if let Some(&Some(&_)) = &mut Some(&Some(0)) {
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:57:17
+  --> $DIR/pattern-errors.rs:56:17
    |
 LL |     if let Some(&mut Some(x)) = &Some(Some(0)) {
    |                 ^^^^^
@@ -77,7 +77,7 @@ LL +     if let Some(&Some(x)) = &Some(Some(0)) {
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:166:10
+  --> $DIR/pattern-errors.rs:158:10
    |
 LL |     let [&mut x] = &[&mut 0];
    |          ^^^^^
@@ -90,7 +90,7 @@ LL +     let [&x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:172:10
+  --> $DIR/pattern-errors.rs:164:10
    |
 LL |     let [&mut &x] = &[&mut 0];
    |          ^^^^^
@@ -103,7 +103,7 @@ LL +     let [&&x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:178:10
+  --> $DIR/pattern-errors.rs:170:10
    |
 LL |     let [&mut &ref x] = &[&mut 0];
    |          ^^^^^
@@ -116,7 +116,7 @@ LL +     let [&&ref x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:184:10
+  --> $DIR/pattern-errors.rs:176:10
    |
 LL |     let [&mut &(mut x)] = &[&mut 0];
    |          ^^^^^
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.rs
index 4173b1819cb..5e677445644 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.rs
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.rs
@@ -48,62 +48,54 @@ pub fn main() {
         //[classic2024,structural2024]~| cannot match inherited `&` with `&mut` pattern
     }
     if let Some(&Some(Some(&mut x))) = &Some(Some(&mut Some(0))) {
-        //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types
+        //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types
         //[stable2021]~| expected `Option<&mut Option<{integer}>>`, found `&_`
-        //[structural2024]~| cannot match inherited `&` with `&mut` pattern
-        // TODO: the error on `structural2021` should be an inherited ref mutability mismatch too
-        #[cfg(classic2024)] let _: u32 = x; // TODO: this should hold on `classic2021` too
+        //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern
+        #[cfg(any(classic2021, classic2024))] let _: u32 = x;
     }
     if let Some(&mut Some(x)) = &Some(Some(0)) {
         //~^ ERROR: mismatched types
-        //[stable2021,classic2021,structural2021]~| expected `Option<{integer}>`, found `&mut _`
-        //[classic2024,structural2024]~| cannot match inherited `&` with `&mut` pattern
-        // TODO: the error on `classic2021` and `structural2021` should be the mutability mismatch
+        //[stable2021]~| expected `Option<{integer}>`, found `&mut _`
+        //[classic2021,structural2021,classic2024,structural2024]~| cannot match inherited `&` with `&mut` pattern
     }
 }
 
 fn structural_errors_0() {
     let &[&mut x] = &&mut [0];
-    //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types
+    //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types
     //[stable2021]~| expected integer, found `&mut _`
-    //[structural2024]~| cannot match inherited `&` with `&mut` pattern
-    // TODO: the error on `structural2021` should be an inherited ref mutability mismatch too
-    #[cfg(classic2024)] let _: u32 = x; // TODO: this should hold for `classic2021` too
+    //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern
+    #[cfg(any(classic2021, classic2024))] let _: u32 = x;
 
     let &[&mut x] = &mut &mut [0];
-    //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types
+    //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types
     //[stable2021]~| types differ in mutability
-    //[structural2024]~| cannot match inherited `&` with `&mut` pattern
-    // TODO: the error on `structural2021` should be an inherited ref mutability mismatch too
-    #[cfg(classic2024)] let _: u32 = x; // TODO: this should hold for `classic2021` too
+    //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern
+    #[cfg(any(classic2021, classic2024))] let _: u32 = x;
 
     let &[&mut ref x] = &&mut [0];
-    //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types
+    //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types
     //[stable2021]~| expected integer, found `&mut _`
-    //[structural2024]~| cannot match inherited `&` with `&mut` pattern
-    // TODO: the error on `structural2021` should be an inherited ref mutability mismatch too
-    #[cfg(classic2024)] let _: &u32 = x; // TODO: this should hold for `classic2021` too
+    //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern
+    #[cfg(any(classic2021, classic2024))] let _: &u32 = x;
 
     let &[&mut ref x] = &mut &mut [0];
-    //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types
+    //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types
     //[stable2021]~| types differ in mutability
-    //[structural2024]~| cannot match inherited `&` with `&mut` pattern
-    // TODO: the error on `structural2021` should be an inherited ref mutability mismatch too
-    #[cfg(classic2024)] let _: &u32 = x; // TODO: this should hold for `classic2021` too
+    //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern
+    #[cfg(any(classic2021, classic2024))] let _: &u32 = x;
 
     let &[&mut mut x] = &&mut [0];
-    //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types
+    //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types
     //[stable2021]~| expected integer, found `&mut _`
-    //[structural2024]~| cannot match inherited `&` with `&mut` pattern
-    // TODO: the error on `structural2021` should be an inherited ref mutability mismatch too
-    #[cfg(classic2024)] let _: u32 = x; // TODO: this should hold for `classic2021` too
+    //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern
+    #[cfg(any(classic2021, classic2024))] let _: u32 = x;
 
     let &[&mut mut x] = &mut &mut [0];
-    //[stable2021,classic2021,structural2021,structural2024]~^ ERROR: mismatched types
+    //[stable2021,structural2021,structural2024]~^ ERROR: mismatched types
     //[stable2021]~| types differ in mutability
-    //[structural2024]~| cannot match inherited `&` with `&mut` pattern
-    // TODO: the error on `structural2021` should be an inherited ref mutability mismatch too
-    #[cfg(classic2024)] let _: u32 = x; // TODO: this should hold for `classic2021` too
+    //[structural2021,structural2024]~| cannot match inherited `&` with `&mut` pattern
+    #[cfg(any(classic2021, classic2024))] let _: u32 = x;
 }
 
 fn structural_errors_1() {
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.stable2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.stable2021.stderr
index ad9541b71a0..76e6d2f562a 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.stable2021.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.stable2021.stderr
@@ -59,7 +59,7 @@ LL |     if let Some(&Some(Some(&mut x))) = &Some(Some(&mut Some(0))) {
            found reference `&_`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:57:17
+  --> $DIR/pattern-errors.rs:56:17
    |
 LL |     if let Some(&mut Some(x)) = &Some(Some(0)) {
    |                 ^^^^^^^^^^^^    -------------- this expression has type `&Option<Option<{integer}>>`
@@ -70,7 +70,7 @@ LL |     if let Some(&mut Some(x)) = &Some(Some(0)) {
            found mutable reference `&mut _`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:66:11
+  --> $DIR/pattern-errors.rs:64:11
    |
 LL |     let &[&mut x] = &&mut [0];
    |           ^^^^^^    --------- this expression has type `&&mut [{integer}; 1]`
@@ -80,7 +80,7 @@ LL |     let &[&mut x] = &&mut [0];
    = note:           expected type `{integer}`
            found mutable reference `&mut _`
 note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:66:11
+  --> $DIR/pattern-errors.rs:64:11
    |
 LL |     let &[&mut x] = &&mut [0];
    |           ^^^^^^
@@ -91,7 +91,7 @@ LL +     let &[x] = &&mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:73:9
+  --> $DIR/pattern-errors.rs:70:9
    |
 LL |     let &[&mut x] = &mut &mut [0];
    |         ^^^^^^^^^   ------------- this expression has type `&mut &mut [{integer}; 1]`
@@ -102,7 +102,7 @@ LL |     let &[&mut x] = &mut &mut [0];
                       found reference `&_`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:80:11
+  --> $DIR/pattern-errors.rs:76:11
    |
 LL |     let &[&mut ref x] = &&mut [0];
    |           ^^^^^^^^^^    --------- this expression has type `&&mut [{integer}; 1]`
@@ -112,7 +112,7 @@ LL |     let &[&mut ref x] = &&mut [0];
    = note:           expected type `{integer}`
            found mutable reference `&mut _`
 note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:80:11
+  --> $DIR/pattern-errors.rs:76:11
    |
 LL |     let &[&mut ref x] = &&mut [0];
    |           ^^^^^^^^^^
@@ -123,7 +123,7 @@ LL +     let &[ref x] = &&mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:87:9
+  --> $DIR/pattern-errors.rs:82:9
    |
 LL |     let &[&mut ref x] = &mut &mut [0];
    |         ^^^^^^^^^^^^^   ------------- this expression has type `&mut &mut [{integer}; 1]`
@@ -134,7 +134,7 @@ LL |     let &[&mut ref x] = &mut &mut [0];
                       found reference `&_`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:94:11
+  --> $DIR/pattern-errors.rs:88:11
    |
 LL |     let &[&mut mut x] = &&mut [0];
    |           ^^^^^^^^^^    --------- this expression has type `&&mut [{integer}; 1]`
@@ -144,7 +144,7 @@ LL |     let &[&mut mut x] = &&mut [0];
    = note:           expected type `{integer}`
            found mutable reference `&mut _`
 note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:94:11
+  --> $DIR/pattern-errors.rs:88:11
    |
 LL |     let &[&mut mut x] = &&mut [0];
    |           ^^^^^^^^^^
@@ -155,7 +155,7 @@ LL +     let &[mut x] = &&mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:101:9
+  --> $DIR/pattern-errors.rs:94:9
    |
 LL |     let &[&mut mut x] = &mut &mut [0];
    |         ^^^^^^^^^^^^^   ------------- this expression has type `&mut &mut [{integer}; 1]`
@@ -166,7 +166,7 @@ LL |     let &[&mut mut x] = &mut &mut [0];
                       found reference `&_`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:122:10
+  --> $DIR/pattern-errors.rs:114:10
    |
 LL |     let [&&mut x] = &[&mut 0];
    |          ^^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -177,7 +177,7 @@ LL |     let [&&mut x] = &[&mut 0];
                       found reference `&_`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:129:10
+  --> $DIR/pattern-errors.rs:121:10
    |
 LL |     let [&&mut x] = &mut [&mut 0];
    |          ^^^^^^^    ------------- this expression has type `&mut [&mut {integer}; 1]`
@@ -188,7 +188,7 @@ LL |     let [&&mut x] = &mut [&mut 0];
                       found reference `&_`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:136:10
+  --> $DIR/pattern-errors.rs:128:10
    |
 LL |     let [&&mut ref x] = &[&mut 0];
    |          ^^^^^^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -199,7 +199,7 @@ LL |     let [&&mut ref x] = &[&mut 0];
                       found reference `&_`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:143:10
+  --> $DIR/pattern-errors.rs:135:10
    |
 LL |     let [&&mut ref x] = &mut [&mut 0];
    |          ^^^^^^^^^^^    ------------- this expression has type `&mut [&mut {integer}; 1]`
@@ -210,7 +210,7 @@ LL |     let [&&mut ref x] = &mut [&mut 0];
                       found reference `&_`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:150:10
+  --> $DIR/pattern-errors.rs:142:10
    |
 LL |     let [&&mut mut x] = &[&mut 0];
    |          ^^^^^^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -221,7 +221,7 @@ LL |     let [&&mut mut x] = &[&mut 0];
                       found reference `&_`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:157:10
+  --> $DIR/pattern-errors.rs:149:10
    |
 LL |     let [&&mut mut x] = &mut [&mut 0];
    |          ^^^^^^^^^^^    ------------- this expression has type `&mut [&mut {integer}; 1]`
@@ -232,7 +232,7 @@ LL |     let [&&mut mut x] = &mut [&mut 0];
                       found reference `&_`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:172:15
+  --> $DIR/pattern-errors.rs:164:15
    |
 LL |     let [&mut &x] = &[&mut 0];
    |               ^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -248,7 +248,7 @@ LL +     let [&mut x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:178:15
+  --> $DIR/pattern-errors.rs:170:15
    |
 LL |     let [&mut &ref x] = &[&mut 0];
    |               ^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -264,7 +264,7 @@ LL +     let [&mut ref x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:184:15
+  --> $DIR/pattern-errors.rs:176:15
    |
 LL |     let [&mut &(mut x)] = &[&mut 0];
    |               ^^^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2021.stderr
index e039884cdb1..1ca6bff3f38 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2021.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2021.stderr
@@ -58,155 +58,111 @@ LL |     if let Some(&Some(&mut _)) = &mut Some(&Some(0)) {
            found mutable reference `&mut _`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:50:17
+  --> $DIR/pattern-errors.rs:50:28
    |
 LL |     if let Some(&Some(Some(&mut x))) = &Some(Some(&mut Some(0))) {
-   |                 ^^^^^^^^^^^^^^^^^^^    ------------------------- this expression has type `&Option<Option<&mut Option<{integer}>>>`
-   |                 |
-   |                 expected `Option<&mut Option<{integer}>>`, found `&_`
+   |                            ^^^^^
+   |
+   = note: cannot match inherited `&` with `&mut` pattern
+help: replace this `&mut` pattern with `&`
+   |
+LL -     if let Some(&Some(Some(&mut x))) = &Some(Some(&mut Some(0))) {
+LL +     if let Some(&Some(Some(&x))) = &Some(Some(&mut Some(0))) {
    |
-   = note:   expected enum `Option<&mut Option<{integer}>>`
-           found reference `&_`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:57:17
+  --> $DIR/pattern-errors.rs:56:17
    |
 LL |     if let Some(&mut Some(x)) = &Some(Some(0)) {
-   |                 ^^^^^^^^^^^^    -------------- this expression has type `&Option<Option<{integer}>>`
-   |                 |
-   |                 expected `Option<{integer}>`, found `&mut _`
+   |                 ^^^^^
+   |
+   = note: cannot match inherited `&` with `&mut` pattern
+help: replace this `&mut` pattern with `&`
+   |
+LL -     if let Some(&mut Some(x)) = &Some(Some(0)) {
+LL +     if let Some(&Some(x)) = &Some(Some(0)) {
    |
-   = note:           expected enum `Option<{integer}>`
-           found mutable reference `&mut _`
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:66:11
+  --> $DIR/pattern-errors.rs:64:11
    |
 LL |     let &[&mut x] = &&mut [0];
-   |           ^^^^^^    --------- this expression has type `&&mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
+   |           ^^^^^
    |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:66:11
-   |
-LL |     let &[&mut x] = &&mut [0];
-   |           ^^^^^^
-help: consider removing `&mut` from the pattern
+   = note: cannot match inherited `&` with `&mut` pattern
+help: replace this `&mut` pattern with `&`
    |
 LL -     let &[&mut x] = &&mut [0];
-LL +     let &[x] = &&mut [0];
+LL +     let &[&x] = &&mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:73:11
+  --> $DIR/pattern-errors.rs:70:11
    |
 LL |     let &[&mut x] = &mut &mut [0];
-   |           ^^^^^^    ------------- this expression has type `&mut &mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
+   |           ^^^^^
    |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:73:11
-   |
-LL |     let &[&mut x] = &mut &mut [0];
-   |           ^^^^^^
-help: consider removing `&mut` from the pattern
+   = note: cannot match inherited `&` with `&mut` pattern
+help: replace this `&mut` pattern with `&`
    |
 LL -     let &[&mut x] = &mut &mut [0];
-LL +     let &[x] = &mut &mut [0];
+LL +     let &[&x] = &mut &mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:80:11
+  --> $DIR/pattern-errors.rs:76:11
    |
 LL |     let &[&mut ref x] = &&mut [0];
-   |           ^^^^^^^^^^    --------- this expression has type `&&mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
+   |           ^^^^^
    |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:80:11
-   |
-LL |     let &[&mut ref x] = &&mut [0];
-   |           ^^^^^^^^^^
-help: consider removing `&mut` from the pattern
+   = note: cannot match inherited `&` with `&mut` pattern
+help: replace this `&mut` pattern with `&`
    |
 LL -     let &[&mut ref x] = &&mut [0];
-LL +     let &[ref x] = &&mut [0];
+LL +     let &[&ref x] = &&mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:87:11
+  --> $DIR/pattern-errors.rs:82:11
    |
 LL |     let &[&mut ref x] = &mut &mut [0];
-   |           ^^^^^^^^^^    ------------- this expression has type `&mut &mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
+   |           ^^^^^
    |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:87:11
-   |
-LL |     let &[&mut ref x] = &mut &mut [0];
-   |           ^^^^^^^^^^
-help: consider removing `&mut` from the pattern
+   = note: cannot match inherited `&` with `&mut` pattern
+help: replace this `&mut` pattern with `&`
    |
 LL -     let &[&mut ref x] = &mut &mut [0];
-LL +     let &[ref x] = &mut &mut [0];
+LL +     let &[&ref x] = &mut &mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:94:11
+  --> $DIR/pattern-errors.rs:88:11
    |
 LL |     let &[&mut mut x] = &&mut [0];
-   |           ^^^^^^^^^^    --------- this expression has type `&&mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
+   |           ^^^^^
    |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:94:11
-   |
-LL |     let &[&mut mut x] = &&mut [0];
-   |           ^^^^^^^^^^
-help: consider removing `&mut` from the pattern
+   = note: cannot match inherited `&` with `&mut` pattern
+help: replace this `&mut` pattern with `&`
    |
 LL -     let &[&mut mut x] = &&mut [0];
-LL +     let &[mut x] = &&mut [0];
+LL +     let &[&mut x] = &&mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:101:11
+  --> $DIR/pattern-errors.rs:94:11
    |
 LL |     let &[&mut mut x] = &mut &mut [0];
-   |           ^^^^^^^^^^    ------------- this expression has type `&mut &mut [{integer}; 1]`
-   |           |
-   |           expected integer, found `&mut _`
+   |           ^^^^^
    |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/pattern-errors.rs:101:11
-   |
-LL |     let &[&mut mut x] = &mut &mut [0];
-   |           ^^^^^^^^^^
-help: consider removing `&mut` from the pattern
+   = note: cannot match inherited `&` with `&mut` pattern
+help: replace this `&mut` pattern with `&`
    |
 LL -     let &[&mut mut x] = &mut &mut [0];
-LL +     let &[mut x] = &mut &mut [0];
+LL +     let &[&mut x] = &mut &mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:122:11
+  --> $DIR/pattern-errors.rs:114:11
    |
 LL |     let [&&mut x] = &[&mut 0];
    |           ^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -222,7 +178,7 @@ LL +     let [&x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:129:11
+  --> $DIR/pattern-errors.rs:121:11
    |
 LL |     let [&&mut x] = &mut [&mut 0];
    |           ^^^^^^    ------------- this expression has type `&mut [&mut {integer}; 1]`
@@ -238,7 +194,7 @@ LL +     let [&x] = &mut [&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:136:11
+  --> $DIR/pattern-errors.rs:128:11
    |
 LL |     let [&&mut ref x] = &[&mut 0];
    |           ^^^^^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -254,7 +210,7 @@ LL +     let [&ref x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:143:11
+  --> $DIR/pattern-errors.rs:135:11
    |
 LL |     let [&&mut ref x] = &mut [&mut 0];
    |           ^^^^^^^^^^    ------------- this expression has type `&mut [&mut {integer}; 1]`
@@ -270,7 +226,7 @@ LL +     let [&ref x] = &mut [&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:150:11
+  --> $DIR/pattern-errors.rs:142:11
    |
 LL |     let [&&mut mut x] = &[&mut 0];
    |           ^^^^^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -286,7 +242,7 @@ LL +     let [&mut x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:157:11
+  --> $DIR/pattern-errors.rs:149:11
    |
 LL |     let [&&mut mut x] = &mut [&mut 0];
    |           ^^^^^^^^^^    ------------- this expression has type `&mut [&mut {integer}; 1]`
@@ -302,7 +258,7 @@ LL +     let [&mut x] = &mut [&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:172:15
+  --> $DIR/pattern-errors.rs:164:15
    |
 LL |     let [&mut &x] = &[&mut 0];
    |               ^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -318,7 +274,7 @@ LL +     let [&mut x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:178:15
+  --> $DIR/pattern-errors.rs:170:15
    |
 LL |     let [&mut &ref x] = &[&mut 0];
    |               ^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
@@ -334,7 +290,7 @@ LL +     let [&mut ref x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:184:15
+  --> $DIR/pattern-errors.rs:176:15
    |
 LL |     let [&mut &(mut x)] = &[&mut 0];
    |               ^^^^^^^^    --------- this expression has type `&[&mut {integer}; 1]`
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2024.stderr
index 950d9f8b351..3658893df9c 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2024.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/pattern-errors.structural2024.stderr
@@ -51,7 +51,7 @@ LL +     if let Some(&Some(Some(&x))) = &Some(Some(&mut Some(0))) {
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:57:17
+  --> $DIR/pattern-errors.rs:56:17
    |
 LL |     if let Some(&mut Some(x)) = &Some(Some(0)) {
    |                 ^^^^^
@@ -64,7 +64,7 @@ LL +     if let Some(&Some(x)) = &Some(Some(0)) {
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:66:11
+  --> $DIR/pattern-errors.rs:64:11
    |
 LL |     let &[&mut x] = &&mut [0];
    |           ^^^^^
@@ -77,7 +77,7 @@ LL +     let &[&x] = &&mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:73:11
+  --> $DIR/pattern-errors.rs:70:11
    |
 LL |     let &[&mut x] = &mut &mut [0];
    |           ^^^^^
@@ -90,7 +90,7 @@ LL +     let &[&x] = &mut &mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:80:11
+  --> $DIR/pattern-errors.rs:76:11
    |
 LL |     let &[&mut ref x] = &&mut [0];
    |           ^^^^^
@@ -103,7 +103,7 @@ LL +     let &[&ref x] = &&mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:87:11
+  --> $DIR/pattern-errors.rs:82:11
    |
 LL |     let &[&mut ref x] = &mut &mut [0];
    |           ^^^^^
@@ -116,7 +116,7 @@ LL +     let &[&ref x] = &mut &mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:94:11
+  --> $DIR/pattern-errors.rs:88:11
    |
 LL |     let &[&mut mut x] = &&mut [0];
    |           ^^^^^
@@ -129,7 +129,7 @@ LL +     let &[&mut x] = &&mut [0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:101:11
+  --> $DIR/pattern-errors.rs:94:11
    |
 LL |     let &[&mut mut x] = &mut &mut [0];
    |           ^^^^^
@@ -142,7 +142,7 @@ LL +     let &[&mut x] = &mut &mut [0];
    |
 
 error[E0658]: binding cannot be both mutable and by-reference
-  --> $DIR/pattern-errors.rs:110:12
+  --> $DIR/pattern-errors.rs:102:12
    |
 LL |     let [&(mut x)] = &[&0];
    |            ^^^^
@@ -152,7 +152,7 @@ LL |     let [&(mut x)] = &[&0];
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 error[E0658]: binding cannot be both mutable and by-reference
-  --> $DIR/pattern-errors.rs:115:12
+  --> $DIR/pattern-errors.rs:107:12
    |
 LL |     let [&(mut x)] = &mut [&0];
    |            ^^^^
@@ -162,7 +162,7 @@ LL |     let [&(mut x)] = &mut [&0];
    = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:122:11
+  --> $DIR/pattern-errors.rs:114:11
    |
 LL |     let [&&mut x] = &[&mut 0];
    |           ^^^^^
@@ -175,7 +175,7 @@ LL +     let [&&x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:129:11
+  --> $DIR/pattern-errors.rs:121:11
    |
 LL |     let [&&mut x] = &mut [&mut 0];
    |           ^^^^^
@@ -188,7 +188,7 @@ LL +     let [&&x] = &mut [&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:136:11
+  --> $DIR/pattern-errors.rs:128:11
    |
 LL |     let [&&mut ref x] = &[&mut 0];
    |           ^^^^^
@@ -201,7 +201,7 @@ LL +     let [&&ref x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:143:11
+  --> $DIR/pattern-errors.rs:135:11
    |
 LL |     let [&&mut ref x] = &mut [&mut 0];
    |           ^^^^^
@@ -214,7 +214,7 @@ LL +     let [&&ref x] = &mut [&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:150:11
+  --> $DIR/pattern-errors.rs:142:11
    |
 LL |     let [&&mut mut x] = &[&mut 0];
    |           ^^^^^
@@ -227,7 +227,7 @@ LL +     let [&&mut x] = &[&mut 0];
    |
 
 error[E0308]: mismatched types
-  --> $DIR/pattern-errors.rs:157:11
+  --> $DIR/pattern-errors.rs:149:11
    |
 LL |     let [&&mut mut x] = &mut [&mut 0];
    |           ^^^^^
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2021.stderr
index 379ba4a11c5..8127ca92e02 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2021.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2021.stderr
@@ -1,18 +1,7 @@
-error[E0308]: mismatched types
-  --> $DIR/ref-mut-inside-shared-ref-pat.rs:16:17
-   |
-LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { // TODO: `classic2021` and `structural2021` shouldn't have mismatched types
-   |                 ^^^^^^^^^^^^^^^^    ------------------ this expression has type `&mut Option<Option<{integer}>>`
-   |                 |
-   |                 expected `Option<{integer}>`, found `&_`
-   |
-   = note:   expected enum `Option<{integer}>`
-           found reference `&_`
-
 error[E0596]: cannot borrow as mutable inside an `&` pattern
   --> $DIR/ref-mut-inside-shared-ref-pat.rs:16:31
    |
-LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { // TODO: `classic2021` and `structural2021` shouldn't have mismatched types
+LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) {
    |                 -             ^
    |                 |
    |                 help: replace this `&` with `&mut`: `&mut`
@@ -57,7 +46,6 @@ LL |     let &[x] = &mut &mut [0];
    |         |
    |         help: replace this `&` with `&mut`: `&mut`
 
-error: aborting due to 7 previous errors
+error: aborting due to 6 previous errors
 
-Some errors have detailed explanations: E0308, E0596.
-For more information about an error, try `rustc --explain E0308`.
+For more information about this error, try `rustc --explain E0596`.
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.fixed b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.fixed
index 105313a1489..57de9cb4c10 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.fixed
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.fixed
@@ -13,8 +13,8 @@
 #![cfg_attr(any(structural2021, structural2024), feature(ref_pat_eat_one_layer_2024_structural))]
 
 pub fn main() {
-    if let Some(&mut Some(ref mut x)) = &mut Some(Some(0)) { // TODO: `classic2021` and `structural2021` shouldn't have mismatched types
-        //[stable2021,classic2021,structural2021]~^ ERROR: mismatched types
+    if let Some(&mut Some(ref mut x)) = &mut Some(Some(0)) {
+        //[stable2021]~^ ERROR: mismatched types
         //[classic2021,structural2021,classic2024,structural2024]~^^ ERROR: cannot borrow as mutable inside an `&` pattern
         let _: &mut u8 = x;
     }
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.stderr
index 93ddf4d60fd..8127ca92e02 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.classic2024.stderr
@@ -1,7 +1,7 @@
 error[E0596]: cannot borrow as mutable inside an `&` pattern
   --> $DIR/ref-mut-inside-shared-ref-pat.rs:16:31
    |
-LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { // TODO: `classic2021` and `structural2021` shouldn't have mismatched types
+LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) {
    |                 -             ^
    |                 |
    |                 help: replace this `&` with `&mut`: `&mut`
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.rs
index 800aca06396..277ff90b673 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.rs
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.rs
@@ -13,8 +13,8 @@
 #![cfg_attr(any(structural2021, structural2024), feature(ref_pat_eat_one_layer_2024_structural))]
 
 pub fn main() {
-    if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { // TODO: `classic2021` and `structural2021` shouldn't have mismatched types
-        //[stable2021,classic2021,structural2021]~^ ERROR: mismatched types
+    if let Some(&Some(ref mut x)) = &mut Some(Some(0)) {
+        //[stable2021]~^ ERROR: mismatched types
         //[classic2021,structural2021,classic2024,structural2024]~^^ ERROR: cannot borrow as mutable inside an `&` pattern
         let _: &mut u8 = x;
     }
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.stable2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.stable2021.stderr
index 9a3b896d4f8..5fbaacd7281 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.stable2021.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.stable2021.stderr
@@ -1,7 +1,7 @@
 error[E0308]: mismatched types
   --> $DIR/ref-mut-inside-shared-ref-pat.rs:16:17
    |
-LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { // TODO: `classic2021` and `structural2021` shouldn't have mismatched types
+LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) {
    |                 ^^^^^^^^^^^^^^^^    ------------------ this expression has type `&mut Option<Option<{integer}>>`
    |                 |
    |                 expected `Option<{integer}>`, found `&_`
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2021.stderr
index 1a138494b85..e735cfed249 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2021.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2021.stderr
@@ -1,18 +1,7 @@
-error[E0308]: mismatched types
-  --> $DIR/ref-mut-inside-shared-ref-pat.rs:16:17
-   |
-LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { // TODO: `classic2021` and `structural2021` shouldn't have mismatched types
-   |                 ^^^^^^^^^^^^^^^^    ------------------ this expression has type `&mut Option<Option<{integer}>>`
-   |                 |
-   |                 expected `Option<{integer}>`, found `&_`
-   |
-   = note:   expected enum `Option<{integer}>`
-           found reference `&_`
-
 error[E0596]: cannot borrow as mutable inside an `&` pattern
   --> $DIR/ref-mut-inside-shared-ref-pat.rs:16:31
    |
-LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { // TODO: `classic2021` and `structural2021` shouldn't have mismatched types
+LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) {
    |                 -             ^
    |                 |
    |                 help: replace this `&` with `&mut`: `&mut`
@@ -49,7 +38,6 @@ LL |     let &(ref mut a, ref mut b) = &mut (true, false);
    |         |
    |         help: replace this `&` with `&mut`: `&mut`
 
-error: aborting due to 6 previous errors
+error: aborting due to 5 previous errors
 
-Some errors have detailed explanations: E0308, E0596.
-For more information about an error, try `rustc --explain E0308`.
+For more information about this error, try `rustc --explain E0596`.
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.fixed b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.fixed
index 78fbffdb270..bcde4b90f59 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.fixed
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.fixed
@@ -13,8 +13,8 @@
 #![cfg_attr(any(structural2021, structural2024), feature(ref_pat_eat_one_layer_2024_structural))]
 
 pub fn main() {
-    if let Some(&mut Some(ref mut x)) = &mut Some(Some(0)) { // TODO: `classic2021` and `structural2021` shouldn't have mismatched types
-        //[stable2021,classic2021,structural2021]~^ ERROR: mismatched types
+    if let Some(&mut Some(ref mut x)) = &mut Some(Some(0)) {
+        //[stable2021]~^ ERROR: mismatched types
         //[classic2021,structural2021,classic2024,structural2024]~^^ ERROR: cannot borrow as mutable inside an `&` pattern
         let _: &mut u8 = x;
     }
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.stderr
index 11e39abb860..e735cfed249 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-mut-inside-shared-ref-pat.structural2024.stderr
@@ -1,7 +1,7 @@
 error[E0596]: cannot borrow as mutable inside an `&` pattern
   --> $DIR/ref-mut-inside-shared-ref-pat.rs:16:31
    |
-LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) { // TODO: `classic2021` and `structural2021` shouldn't have mismatched types
+LL |     if let Some(&Some(ref mut x)) = &mut Some(Some(0)) {
    |                 -             ^
    |                 |
    |                 help: replace this `&` with `&mut`: `&mut`
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr
index c9195dbfbf5..f784d7e9988 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.classic2021.stderr
@@ -15,54 +15,6 @@ LL +     if let Some(Some(&x)) = &Some(Some(&0)) {
    |
 
 error[E0308]: mismatched types
-  --> $DIR/well-typed-edition-2024.rs:39:22
-   |
-LL |     if let Some(Some(&x)) = &Some(&Some(0)) {
-   |                      ^^     --------------- this expression has type `&Option<&Option<{integer}>>`
-   |                      |
-   |                      expected integer, found `&_`
-   |
-   = note:   expected type `{integer}`
-           found reference `&_`
-help: consider removing `&` from the pattern
-   |
-LL -     if let Some(Some(&x)) = &Some(&Some(0)) {
-LL +     if let Some(Some(x)) = &Some(&Some(0)) {
-   |
-
-error[E0308]: mismatched types
-  --> $DIR/well-typed-edition-2024.rs:44:17
-   |
-LL |     if let Some(&Some(x)) = &Some(Some(0)) {
-   |                 ^^^^^^^^    -------------- this expression has type `&Option<Option<{integer}>>`
-   |                 |
-   |                 expected `Option<{integer}>`, found `&_`
-   |
-   = note:   expected enum `Option<{integer}>`
-           found reference `&_`
-
-error[E0308]: mismatched types
-  --> $DIR/well-typed-edition-2024.rs:49:22
-   |
-LL |     if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) {
-   |                      ^^^^^^     ----------------------- this expression has type `&mut Option<&mut Option<{integer}>>`
-   |                      |
-   |                      expected integer, found `&mut _`
-   |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/well-typed-edition-2024.rs:49:22
-   |
-LL |     if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) {
-   |                      ^^^^^^
-help: consider removing `&mut` from the pattern
-   |
-LL -     if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) {
-LL +     if let Some(Some(x)) = &mut Some(&mut Some(0)) {
-   |
-
-error[E0308]: mismatched types
   --> $DIR/well-typed-edition-2024.rs:63:23
    |
 LL |     if let Some(&Some(&x)) = &Some(&Some(0)) {
@@ -79,28 +31,6 @@ LL +     if let Some(&Some(x)) = &Some(&Some(0)) {
    |
 
 error[E0308]: mismatched types
-  --> $DIR/well-typed-edition-2024.rs:70:17
-   |
-LL |     if let Some(&Some(Some(&x))) = &Some(Some(&mut Some(0))) {
-   |                 ^^^^^^^^^^^^^^^    ------------------------- this expression has type `&Option<Option<&mut Option<{integer}>>>`
-   |                 |
-   |                 expected `Option<&mut Option<{integer}>>`, found `&_`
-   |
-   = note:   expected enum `Option<&mut Option<{integer}>>`
-           found reference `&_`
-
-error[E0308]: mismatched types
-  --> $DIR/well-typed-edition-2024.rs:75:17
-   |
-LL |     if let Some(&Some(x)) = &mut Some(Some(0)) {
-   |                 ^^^^^^^^    ------------------ this expression has type `&mut Option<Option<{integer}>>`
-   |                 |
-   |                 expected `Option<{integer}>`, found `&_`
-   |
-   = note:   expected enum `Option<{integer}>`
-           found reference `&_`
-
-error[E0308]: mismatched types
   --> $DIR/well-typed-edition-2024.rs:82:23
    |
 LL |     if let Some(&Some(&x)) = &Some(&mut Some(0)) {
@@ -249,6 +179,6 @@ LL |     let [&mut &(mut x)] = &mut [&0];
    = note:      expected reference `&{integer}`
            found mutable reference `&mut _`
 
-error: aborting due to 16 previous errors
+error: aborting due to 11 previous errors
 
 For more information about this error, try `rustc --explain E0308`.
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 e61aa5f35c9..851011918fe 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
@@ -37,19 +37,19 @@ pub fn main() {
 
     // Tests for eating a lone inherited reference
     if let Some(Some(&x)) = &Some(&Some(0)) {
-        //[stable2021,classic2021,structural2021]~^ mismatched types
-        //[stable2021,classic2021,structural2021]~| expected integer, found `&_`
-        #[cfg(any(classic2024, structural2024))] let _: u32 = x; // TODO: this should hold on `classic2021` and `structural2021`
+        //[stable2021]~^ mismatched types
+        //[stable2021]~| expected integer, found `&_`
+        #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x;
     }
     if let Some(&Some(x)) = &Some(Some(0)) {
-        //[stable2021,classic2021,structural2021]~^ mismatched types
-        //[stable2021,classic2021,structural2021]~| expected `Option<{integer}>`, found `&_`
-        #[cfg(any(classic2024, structural2024))] let _: u32 = x; // TODO: this should hold on `classic2021` and `structural2021`
+        //[stable2021]~^ 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,classic2021,structural2021]~^ mismatched types
-        //[stable2021,classic2021,structural2021]~| expected integer, found `&mut _`
-        #[cfg(any(classic2024, structural2024))] let _: u32 = x; // TODO: this should hold on `classic2021` and `structural2021`
+        //[stable2021]~^ mismatched types
+        //[stable2021]~| expected integer, found `&mut _`
+        #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x;
     }
 
     // Tests for `&` patterns matching real `&mut` reference types
@@ -68,14 +68,14 @@ pub fn main() {
 
     // Tests for `&` matching a lone inherited possibly-`&mut` reference
     if let Some(&Some(Some(&x))) = &Some(Some(&mut Some(0))) {
-        //[stable2021,classic2021,structural2021]~^ mismatched types
+        //[stable2021]~^ mismatched types
         //[stable2021]~| expected `Option<&mut Option<{integer}>>`, found `&_`
-        #[cfg(any(classic2024, structural2024))] let _: u32 = x; // TODO: this should hold on `classic2021` and `structural2021`
+        #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x;
     }
     if let Some(&Some(x)) = &mut Some(Some(0)) {
-        //[stable2021,classic2021,structural2021]~^ mismatched types
+        //[stable2021]~^ mismatched types
         //[stable2021]~| expected `Option<{integer}>`, found `&_`
-        #[cfg(any(classic2024, structural2024))] let _: u32 = x; // TODO: this should hold on `classic2021` and `structural2021`
+        #[cfg(any(classic2021, structural2021, classic2024, structural2024))] let _: u32 = x;
     }
 
     // Tests eating one layer, eating a lone inherited ref, and `&` eating `&mut` (realness varies)
diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr
index c9195dbfbf5..f784d7e9988 100644
--- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr
+++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/well-typed-edition-2024.structural2021.stderr
@@ -15,54 +15,6 @@ LL +     if let Some(Some(&x)) = &Some(Some(&0)) {
    |
 
 error[E0308]: mismatched types
-  --> $DIR/well-typed-edition-2024.rs:39:22
-   |
-LL |     if let Some(Some(&x)) = &Some(&Some(0)) {
-   |                      ^^     --------------- this expression has type `&Option<&Option<{integer}>>`
-   |                      |
-   |                      expected integer, found `&_`
-   |
-   = note:   expected type `{integer}`
-           found reference `&_`
-help: consider removing `&` from the pattern
-   |
-LL -     if let Some(Some(&x)) = &Some(&Some(0)) {
-LL +     if let Some(Some(x)) = &Some(&Some(0)) {
-   |
-
-error[E0308]: mismatched types
-  --> $DIR/well-typed-edition-2024.rs:44:17
-   |
-LL |     if let Some(&Some(x)) = &Some(Some(0)) {
-   |                 ^^^^^^^^    -------------- this expression has type `&Option<Option<{integer}>>`
-   |                 |
-   |                 expected `Option<{integer}>`, found `&_`
-   |
-   = note:   expected enum `Option<{integer}>`
-           found reference `&_`
-
-error[E0308]: mismatched types
-  --> $DIR/well-typed-edition-2024.rs:49:22
-   |
-LL |     if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) {
-   |                      ^^^^^^     ----------------------- this expression has type `&mut Option<&mut Option<{integer}>>`
-   |                      |
-   |                      expected integer, found `&mut _`
-   |
-   = note:           expected type `{integer}`
-           found mutable reference `&mut _`
-note: to declare a mutable binding use: `mut x`
-  --> $DIR/well-typed-edition-2024.rs:49:22
-   |
-LL |     if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) {
-   |                      ^^^^^^
-help: consider removing `&mut` from the pattern
-   |
-LL -     if let Some(Some(&mut x)) = &mut Some(&mut Some(0)) {
-LL +     if let Some(Some(x)) = &mut Some(&mut Some(0)) {
-   |
-
-error[E0308]: mismatched types
   --> $DIR/well-typed-edition-2024.rs:63:23
    |
 LL |     if let Some(&Some(&x)) = &Some(&Some(0)) {
@@ -79,28 +31,6 @@ LL +     if let Some(&Some(x)) = &Some(&Some(0)) {
    |
 
 error[E0308]: mismatched types
-  --> $DIR/well-typed-edition-2024.rs:70:17
-   |
-LL |     if let Some(&Some(Some(&x))) = &Some(Some(&mut Some(0))) {
-   |                 ^^^^^^^^^^^^^^^    ------------------------- this expression has type `&Option<Option<&mut Option<{integer}>>>`
-   |                 |
-   |                 expected `Option<&mut Option<{integer}>>`, found `&_`
-   |
-   = note:   expected enum `Option<&mut Option<{integer}>>`
-           found reference `&_`
-
-error[E0308]: mismatched types
-  --> $DIR/well-typed-edition-2024.rs:75:17
-   |
-LL |     if let Some(&Some(x)) = &mut Some(Some(0)) {
-   |                 ^^^^^^^^    ------------------ this expression has type `&mut Option<Option<{integer}>>`
-   |                 |
-   |                 expected `Option<{integer}>`, found `&_`
-   |
-   = note:   expected enum `Option<{integer}>`
-           found reference `&_`
-
-error[E0308]: mismatched types
   --> $DIR/well-typed-edition-2024.rs:82:23
    |
 LL |     if let Some(&Some(&x)) = &Some(&mut Some(0)) {
@@ -249,6 +179,6 @@ LL |     let [&mut &(mut x)] = &mut [&0];
    = note:      expected reference `&{integer}`
            found mutable reference `&mut _`
 
-error: aborting due to 16 previous errors
+error: aborting due to 11 previous errors
 
 For more information about this error, try `rustc --explain E0308`.