Change error message

This commit is contained in:
Nadrieril 2024-10-08 00:14:35 +02:00
parent 4aaada42d0
commit 2ef0a8fdfd
6 changed files with 57 additions and 58 deletions

View File

@ -265,7 +265,7 @@ mir_build_pointer_pattern = function pointers and raw pointers not derived from
mir_build_privately_uninhabited = pattern `{$witness_1}` is currently uninhabited, but this variant contains private fields which may become inhabited in the future
mir_build_rust_2024_incompatible_pat = the semantics of this pattern will change in edition 2024
mir_build_rust_2024_incompatible_pat = patterns are not allowed to reset the default binding mode in edition 2024
mir_build_rustc_box_attribute_error = `#[rustc_box]` attribute used incorrectly
.attributes = no other attributes may be applied

View File

@ -25,6 +25,7 @@ use tracing::{debug, instrument};
pub(crate) use self::check_match::check_match;
use crate::errors::*;
use crate::fluent_generated as fluent;
use crate::thir::util::UserAnnotatedTyHelpers;
struct PatCtxt<'a, 'tcx> {
@ -58,10 +59,8 @@ pub(super) fn pat_from_hir<'a, 'tcx>(
debug!("pat_from_hir({:?}) = {:?}", pat, result);
if let Some(sugg) = pcx.rust_2024_migration_suggestion {
if sugg.is_hard_error {
let mut err = tcx.dcx().struct_span_err(
pat.span,
"patterns are not allowed to reset the default binding mode in rust 2024",
);
let mut err =
tcx.dcx().struct_span_err(pat.span, fluent::mir_build_rust_2024_incompatible_pat);
err.subdiagnostic(sugg);
err.emit();
} else {

View File

@ -23,22 +23,22 @@ fn main() {
assert_type_eq(x, &mut 0u8);
let &Foo(mut x) = &Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &mut Foo(mut x) = &mut Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &Foo(ref x) = &Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);
let &mut Foo(ref x) = &mut Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);
@ -55,22 +55,22 @@ fn main() {
assert_type_eq(x, &0u8);
let &Foo(&x) = &Foo(&0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &Foo(&mut x) = &Foo(&mut 0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &mut Foo(&x) = &mut Foo(&0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &mut Foo(&mut x) = &mut Foo(&mut 0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
@ -79,25 +79,25 @@ fn main() {
}
if let &&&&&Some(&x) = &&&&&Some(&0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let &&&&&Some(&mut x) = &&&&&Some(&mut 0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let &&&&&mut Some(&x) = &&&&&mut Some(&0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let &mut Some(&mut Some(&mut Some(ref mut x))) = &mut Some(&mut Some(&mut Some(0u8))) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &mut 0u8);
}
@ -109,20 +109,20 @@ fn main() {
}
let &Struct { ref a, mut b, ref c } = &Struct { a: 0, b: 0, c: 0 };
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, 0u32);
let &Struct { a: &a, ref b, ref c } = &Struct { a: &0, b: &0, c: &0 };
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &&0u32);
assert_type_eq(c, &&0u32);
if let &Struct { a: &Some(a), b: &Some(&b), c: &Some(ref c) } =
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
&(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) })
{

View File

@ -23,22 +23,22 @@ fn main() {
assert_type_eq(x, &mut 0u8);
let Foo(mut x) = &Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(mut x) = &mut Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(ref x) = &Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);
let Foo(ref x) = &mut Foo(0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);
@ -55,22 +55,22 @@ fn main() {
assert_type_eq(x, &0u8);
let Foo(&x) = &Foo(&0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(&mut x) = &Foo(&mut 0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(&x) = &mut Foo(&0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(&mut x) = &mut Foo(&mut 0);
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
@ -79,25 +79,25 @@ fn main() {
}
if let Some(&x) = &&&&&Some(&0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let Some(&mut x) = &&&&&Some(&mut 0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let Some(&x) = &&&&&mut Some(&0u8) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) {
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &mut 0u8);
}
@ -109,20 +109,20 @@ fn main() {
}
let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 };
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, &0u32);
assert_type_eq(b, 0u32);
let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 };
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(a, 0u32);
assert_type_eq(b, &&0u32);
assert_type_eq(c, &&0u32);
if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } =
//~^ ERROR: the semantics of this pattern will change in edition 2024
//~^ ERROR: patterns are not allowed to reset the default binding mode
//~| WARN: this changes meaning in Rust 2024
&(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) })
{

View File

@ -1,4 +1,4 @@
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:25:9
|
LL | let Foo(mut x) = &Foo(0);
@ -14,7 +14,7 @@ note: the lint level is defined here
LL | #![deny(rust_2024_incompatible_pat)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:30:9
|
LL | let Foo(mut x) = &mut Foo(0);
@ -25,7 +25,7 @@ LL | let Foo(mut x) = &mut Foo(0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:35:9
|
LL | let Foo(ref x) = &Foo(0);
@ -36,7 +36,7 @@ LL | let Foo(ref x) = &Foo(0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:40:9
|
LL | let Foo(ref x) = &mut Foo(0);
@ -47,7 +47,7 @@ LL | let Foo(ref x) = &mut Foo(0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:57:9
|
LL | let Foo(&x) = &Foo(&0);
@ -58,7 +58,7 @@ LL | let Foo(&x) = &Foo(&0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:62:9
|
LL | let Foo(&mut x) = &Foo(&mut 0);
@ -69,7 +69,7 @@ LL | let Foo(&mut x) = &Foo(&mut 0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:67:9
|
LL | let Foo(&x) = &mut Foo(&0);
@ -80,7 +80,7 @@ LL | let Foo(&x) = &mut Foo(&0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:72:9
|
LL | let Foo(&mut x) = &mut Foo(&mut 0);
@ -91,7 +91,7 @@ LL | let Foo(&mut x) = &mut Foo(&mut 0);
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:81:12
|
LL | if let Some(&x) = &&&&&Some(&0u8) {
@ -102,7 +102,7 @@ LL | if let Some(&x) = &&&&&Some(&0u8) {
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:87:12
|
LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) {
@ -113,7 +113,7 @@ LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) {
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:93:12
|
LL | if let Some(&x) = &&&&&mut Some(&0u8) {
@ -124,7 +124,7 @@ LL | if let Some(&x) = &&&&&mut Some(&0u8) {
= warning: this changes meaning in Rust 2024
= note: for more information, see 123076
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:99:12
|
LL | if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) {
@ -137,7 +137,7 @@ help: desugar the match ergonomics
LL | if let &mut Some(&mut Some(&mut Some(ref mut x))) = &mut Some(&mut Some(&mut Some(0u8))) {
| ++++ ++++ +++++++
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:111:9
|
LL | let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 };
@ -150,7 +150,7 @@ help: desugar the match ergonomics
LL | let &Struct { ref a, mut b, ref c } = &Struct { a: 0, b: 0, c: 0 };
| + +++ +++
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:117:9
|
LL | let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 };
@ -163,7 +163,7 @@ help: desugar the match ergonomics
LL | let &Struct { a: &a, ref b, ref c } = &Struct { a: &0, b: &0, c: &0 };
| + +++
error: the semantics of this pattern will change in edition 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:124:12
|
LL | if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } =
@ -176,7 +176,7 @@ help: desugar the match ergonomics
LL | if let &Struct { a: &Some(a), b: &Some(&b), c: &Some(ref c) } =
| + + + +++
error: patterns are not allowed to reset the default binding mode in rust 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/migration_lint.rs:137:9
|
LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {

View File

@ -99,7 +99,7 @@ LL - test_pat_on_type![Foo { f: (&x,) }: &mut Foo];
LL + test_pat_on_type![Foo { f: (x,) }: &mut Foo];
|
error: patterns are not allowed to reset the default binding mode in rust 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:25:19
|
LL | test_pat_on_type![(&x,): &(&T,)];
@ -107,7 +107,7 @@ LL | test_pat_on_type![(&x,): &(&T,)];
| |
| help: desugar the match ergonomics: `&`
error: patterns are not allowed to reset the default binding mode in rust 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:28:19
|
LL | test_pat_on_type![(&mut x,): &(&mut T,)];
@ -115,7 +115,7 @@ LL | test_pat_on_type![(&mut x,): &(&mut T,)];
| |
| help: desugar the match ergonomics: `&`
error: patterns are not allowed to reset the default binding mode in rust 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:32:19
|
LL | test_pat_on_type![Foo { f: &(x,) }: &Foo];
@ -123,7 +123,7 @@ LL | test_pat_on_type![Foo { f: &(x,) }: &Foo];
| |
| help: desugar the match ergonomics: `&`
error: patterns are not allowed to reset the default binding mode in rust 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:33:19
|
LL | test_pat_on_type![(mut x,): &(T,)];
@ -131,7 +131,7 @@ LL | test_pat_on_type![(mut x,): &(T,)];
| |
| help: desugar the match ergonomics: `&`
error: patterns are not allowed to reset the default binding mode in rust 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:34:19
|
LL | test_pat_on_type![(ref x,): &(T,)];
@ -139,7 +139,7 @@ LL | test_pat_on_type![(ref x,): &(T,)];
| |
| help: desugar the match ergonomics: `&`
error: patterns are not allowed to reset the default binding mode in rust 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:35:19
|
LL | test_pat_on_type![(ref mut x,): &mut (T,)];
@ -147,7 +147,7 @@ LL | test_pat_on_type![(ref mut x,): &mut (T,)];
| |
| help: desugar the match ergonomics: `&mut`
error: patterns are not allowed to reset the default binding mode in rust 2024
error: patterns are not allowed to reset the default binding mode in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:44:9
|
LL | (&x,) => x,