From a5cc4cbe64876c339cc1fb47fb962792bc142146 Mon Sep 17 00:00:00 2001 From: dianne Date: Wed, 5 Feb 2025 09:05:39 -0800 Subject: [PATCH] reword default binding mode notes --- compiler/rustc_mir_build/src/errors.rs | 12 +-- ...nding-on-inh-ref-errors.classic2024.stderr | 16 ++-- ...ng-on-inh-ref-errors.structural2024.stderr | 44 +++++------ .../migration_lint.stderr | 76 +++++++++---------- .../min_match_ergonomics_fail.stderr | 28 +++---- 5 files changed, 85 insertions(+), 91 deletions(-) diff --git a/compiler/rustc_mir_build/src/errors.rs b/compiler/rustc_mir_build/src/errors.rs index e83901e175d1..55fd42457b7e 100644 --- a/compiler/rustc_mir_build/src/errors.rs +++ b/compiler/rustc_mir_build/src/errors.rs @@ -1128,15 +1128,9 @@ impl Subdiagnostic for Rust2024IncompatiblePatSugg { for (span, def_br_mutbl) in self.default_mode_labels.into_iter().rev() { // Don't point to a macro call site. if !span.from_expansion() { - let dbm_str = match def_br_mutbl { - ty::Mutability::Not => "ref", - ty::Mutability::Mut => "ref mut", - }; - let note_msg = format!( - "the default binding mode changed to `{dbm_str}` because this has type `{}_`", - def_br_mutbl.ref_prefix_str() - ); - let label_msg = format!("the default binding mode is `{dbm_str}`, introduced here"); + let note_msg = "matching on a reference type with a non-reference pattern changes the default binding mode"; + let label_msg = + format!("this matches on type `{}_`", def_br_mutbl.ref_prefix_str()); let mut label = MultiSpan::from(span); label.push_span_label(span, label_msg); diag.span_note(label, note_msg); diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr index 74e164619fa9..b7fb70dfd246 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr @@ -17,11 +17,11 @@ LL | let [ref mut x] = &[0]; | ^^^^^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:67:9 | LL | let [ref mut x] = &[0]; - | ^^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[ref mut x] = &[0]; @@ -40,11 +40,11 @@ LL | let [ref x] = &[0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:75:9 | LL | let [ref x] = &[0]; - | ^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[ref x] = &[0]; @@ -57,11 +57,11 @@ LL | let [ref x] = &mut [0]; | ^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:79:9 | LL | let [ref x] = &mut [0]; - | ^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [ref x] = &mut [0]; @@ -74,11 +74,11 @@ LL | let [ref mut x] = &mut [0]; | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:83:9 | LL | let [ref mut x] = &mut [0]; - | ^^^^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [ref mut x] = &mut [0]; diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr index 422c169d7fd1..31930e8c0337 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr @@ -5,11 +5,11 @@ LL | let [&ref x] = &[&0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:15:9 | LL | let [&ref x] = &[&0]; - | ^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[&ref x] = &[&0]; @@ -22,11 +22,11 @@ LL | let [&ref x] = &mut [&0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:20:9 | LL | let [&ref x] = &mut [&0]; - | ^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [&ref x] = &mut [&0]; @@ -39,11 +39,11 @@ LL | let [&mut ref x] = &mut [&mut 0]; | ^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:25:9 | LL | let [&mut ref x] = &mut [&mut 0]; - | ^^^^^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [&mut ref x] = &mut [&mut 0]; @@ -56,11 +56,11 @@ LL | let [&mut ref mut x] = &mut [&mut 0]; | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:30:9 | LL | let [&mut ref mut x] = &mut [&mut 0]; - | ^^^^^^^^^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [&mut ref mut x] = &mut [&mut 0]; @@ -73,11 +73,11 @@ LL | let [&ref x] = &[&mut 0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:39:9 | LL | let [&ref x] = &[&mut 0]; - | ^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[&ref x] = &[&mut 0]; @@ -90,11 +90,11 @@ LL | let [&ref x] = &mut [&mut 0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:45:9 | LL | let [&ref x] = &mut [&mut 0]; - | ^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [&ref x] = &mut [&mut 0]; @@ -107,11 +107,11 @@ LL | let [&mut ref x] = &[&mut 0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:54:9 | LL | let [&mut ref x] = &[&mut 0]; - | ^^^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[&mut ref x] = &[&mut 0]; @@ -124,11 +124,11 @@ LL | let [ref mut x] = &[0]; | ^^^^^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:67:9 | LL | let [ref mut x] = &[0]; - | ^^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[ref mut x] = &[0]; @@ -147,11 +147,11 @@ LL | let [ref x] = &[0]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:75:9 | LL | let [ref x] = &[0]; - | ^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[ref x] = &[0]; @@ -164,11 +164,11 @@ LL | let [ref x] = &mut [0]; | ^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:79:9 | LL | let [ref x] = &mut [0]; - | ^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [ref x] = &mut [0]; @@ -181,11 +181,11 @@ LL | let [ref mut x] = &mut [0]; | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/ref-binding-on-inh-ref-errors.rs:83:9 | LL | let [ref mut x] = &mut [0]; - | ^^^^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [ref mut x] = &mut [0]; diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr index cfbd260e0e9a..ea3283d3a921 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr @@ -6,11 +6,11 @@ LL | let Foo(mut x) = &Foo(0); | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:25:9 | LL | let Foo(mut x) = &Foo(0); - | ^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^ this matches on type `&_` note: the lint level is defined here --> $DIR/migration_lint.rs:7:9 | @@ -29,11 +29,11 @@ LL | let Foo(mut x) = &mut Foo(0); | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:30:9 | LL | let Foo(mut x) = &mut Foo(0); - | ^^^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut Foo(mut x) = &mut Foo(0); @@ -47,11 +47,11 @@ LL | let Foo(ref x) = &Foo(0); | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:35:9 | LL | let Foo(ref x) = &Foo(0); - | ^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &Foo(ref x) = &Foo(0); @@ -65,11 +65,11 @@ LL | let Foo(ref x) = &mut Foo(0); | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:40:9 | LL | let Foo(ref x) = &mut Foo(0); - | ^^^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut Foo(ref x) = &mut Foo(0); @@ -83,11 +83,11 @@ LL | let Foo(&x) = &Foo(&0); | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:57:9 | LL | let Foo(&x) = &Foo(&0); - | ^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &Foo(&x) = &Foo(&0); @@ -101,11 +101,11 @@ LL | let Foo(&mut x) = &Foo(&mut 0); | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:62:9 | LL | let Foo(&mut x) = &Foo(&mut 0); - | ^^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &Foo(&mut x) = &Foo(&mut 0); @@ -119,11 +119,11 @@ LL | let Foo(&x) = &mut Foo(&0); | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:67:9 | LL | let Foo(&x) = &mut Foo(&0); - | ^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut Foo(&x) = &mut Foo(&0); @@ -137,11 +137,11 @@ LL | let Foo(&mut x) = &mut Foo(&mut 0); | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:72:9 | LL | let Foo(&mut x) = &mut Foo(&mut 0); - | ^^^^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut Foo(&mut x) = &mut Foo(&mut 0); @@ -155,11 +155,11 @@ LL | if let Some(&x) = &&&&&Some(&0u8) { | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:81:12 | LL | if let Some(&x) = &&&&&Some(&0u8) { - | ^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^ this matches on type `&_` help: make the implied reference patterns explicit | LL | if let &&&&&Some(&x) = &&&&&Some(&0u8) { @@ -173,11 +173,11 @@ LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) { | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:87:12 | LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) { - | ^^^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference patterns explicit | LL | if let &&&&&Some(&mut x) = &&&&&Some(&mut 0u8) { @@ -191,11 +191,11 @@ LL | if let Some(&x) = &&&&&mut Some(&0u8) { | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:93:12 | LL | if let Some(&x) = &&&&&mut Some(&0u8) { - | ^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^ this matches on type `&_` help: make the implied reference patterns explicit | LL | if let &&&&&mut Some(&x) = &&&&&mut Some(&0u8) { @@ -209,11 +209,11 @@ LL | if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:99:12 | LL | if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference patterns and variable binding mode explicit | LL | if let &mut Some(&mut Some(&mut Some(ref mut x))) = &mut Some(&mut Some(&mut Some(0u8))) { @@ -227,11 +227,11 @@ LL | let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 }; | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:111:9 | LL | let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 }; - | ^^^^^^^^^^^^^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern and variable binding modes explicit | LL | let &Struct { ref a, mut b, ref c } = &Struct { a: 0, b: 0, c: 0 }; @@ -247,11 +247,11 @@ LL | let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 }; | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:117:9 | LL | let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern and variable binding mode explicit | LL | let &Struct { a: &a, ref b, ref c } = &Struct { a: &0, b: &0, c: &0 }; @@ -267,11 +267,11 @@ LL | if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } = | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:124:12 | LL | if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } = - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference patterns and variable binding mode explicit | LL | if let &Struct { a: &Some(a), b: &Some(&b), c: &Some(ref c) } = @@ -286,11 +286,11 @@ LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => { | binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:137:9 | LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` = note: this error originates in the macro `migration_lint_macros::mixed_edition_pat` (in Nightly builds, run with -Z macro-backtrace for more info) help: make the implied reference pattern explicit | @@ -307,16 +307,16 @@ LL | let [&mut [ref a]] = &mut [&mut &[0]]; | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:145:15 | LL | let [&mut [ref a]] = &mut [&mut &[0]]; - | ^^^^^^^ the default binding mode is `ref`, introduced here -note: the default binding mode changed to `ref mut` because this has type `&mut _` + | ^^^^^^^ this matches on type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:145:9 | LL | let [&mut [ref a]] = &mut [&mut &[0]]; - | ^^^^^^^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference patterns explicit | LL | let &mut [&mut &[ref a]] = &mut [&mut &[0]]; @@ -330,11 +330,11 @@ LL | let [&(_)] = &[&0]; | = warning: this changes meaning in Rust 2024 = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/migration_lint.rs:150:9 | LL | let [&(_)] = &[&0]; - | ^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[&(_)] = &[&0]; diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr index 1d13723370e7..aaa448ea334f 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr @@ -106,11 +106,11 @@ LL | test_pat_on_type![(&x,): &(&T,)]; | ^ reference pattern not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/min_match_ergonomics_fail.rs:24:19 | LL | test_pat_on_type![(&x,): &(&T,)]; - | ^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | test_pat_on_type![&(&x,): &(&T,)]; @@ -123,11 +123,11 @@ LL | test_pat_on_type![(&mut x,): &(&mut T,)]; | ^^^^ reference pattern not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/min_match_ergonomics_fail.rs:27:19 | LL | test_pat_on_type![(&mut x,): &(&mut T,)]; - | ^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | test_pat_on_type![&(&mut x,): &(&mut T,)]; @@ -140,11 +140,11 @@ LL | test_pat_on_type![Foo { f: &(x,) }: &Foo]; | ^ reference pattern not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/min_match_ergonomics_fail.rs:31:19 | LL | test_pat_on_type![Foo { f: &(x,) }: &Foo]; - | ^^^^^^^^^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | test_pat_on_type![&Foo { f: &(x,) }: &Foo]; @@ -157,11 +157,11 @@ LL | test_pat_on_type![(mut x,): &(T,)]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/min_match_ergonomics_fail.rs:32:19 | LL | test_pat_on_type![(mut x,): &(T,)]; - | ^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | test_pat_on_type![&(mut x,): &(T,)]; @@ -174,11 +174,11 @@ LL | test_pat_on_type![(ref x,): &(T,)]; | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/min_match_ergonomics_fail.rs:33:19 | LL | test_pat_on_type![(ref x,): &(T,)]; - | ^^^^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | test_pat_on_type![&(ref x,): &(T,)]; @@ -191,11 +191,11 @@ LL | test_pat_on_type![(ref mut x,): &mut (T,)]; | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref mut` because this has type `&mut _` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/min_match_ergonomics_fail.rs:34:19 | LL | test_pat_on_type![(ref mut x,): &mut (T,)]; - | ^^^^^^^^^^^^ the default binding mode is `ref mut`, introduced here + | ^^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | test_pat_on_type![&mut (ref mut x,): &mut (T,)]; @@ -208,11 +208,11 @@ LL | (&x,) => x, | ^ reference pattern not allowed under `ref` default binding mode | = note: for more information, see -note: the default binding mode changed to `ref` because this has type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode --> $DIR/min_match_ergonomics_fail.rs:43:9 | LL | (&x,) => x, - | ^^^^^ the default binding mode is `ref`, introduced here + | ^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | &(&x,) => x,