Improve the pattern migration 2024 migration lint's message

This commit is contained in:
dianne 2024-12-17 10:00:15 -08:00
parent 70b8527377
commit 77e9051e22
6 changed files with 63 additions and 63 deletions

View file

@ -285,7 +285,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 = pattern uses features incompatible with edition 2024
mir_build_rust_2024_incompatible_pat = this pattern relies on behavior which may change in edition 2024
mir_build_rustc_box_attribute_error = `#[rustc_box]` attribute used incorrectly
.attributes = no other attributes may be applied

View file

@ -23,22 +23,22 @@ fn main() {
assert_type_eq(x, &mut 0u8);
let &Foo(mut x) = &Foo(0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &mut Foo(mut x) = &mut Foo(0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &Foo(ref x) = &Foo(0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);
let &mut Foo(ref x) = &mut Foo(0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &Foo(&mut x) = &Foo(&mut 0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &mut Foo(&x) = &mut Foo(&0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let &mut Foo(&mut x) = &mut Foo(&mut 0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let &&&&&Some(&mut x) = &&&&&Some(&mut 0u8) {
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let &&&&&mut Some(&x) = &&&&&mut Some(&0u8) {
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
&(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) })
{
@ -135,7 +135,7 @@ fn main() {
// The two patterns are the same syntactically, but because they're defined in different
// editions they don't mean the same thing.
&(Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
assert_type_eq(x, 0u32);
assert_type_eq(y, 0u32);
}

View file

@ -23,22 +23,22 @@ fn main() {
assert_type_eq(x, &mut 0u8);
let Foo(mut x) = &Foo(0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(mut x) = &mut Foo(0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(ref x) = &Foo(0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, &0u8);
let Foo(ref x) = &mut Foo(0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(&mut x) = &Foo(&mut 0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(&x) = &mut Foo(&0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
let Foo(&mut x) = &mut Foo(&mut 0);
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let Some(&mut x) = &&&&&Some(&mut 0u8) {
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
assert_type_eq(x, 0u8);
}
if let Some(&x) = &&&&&mut Some(&0u8) {
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| 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: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
//~| WARN: this changes meaning in Rust 2024
&(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) })
{
@ -135,7 +135,7 @@ fn main() {
// The two patterns are the same syntactically, but because they're defined in different
// editions they don't mean the same thing.
(Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
//~^ ERROR: pattern uses features incompatible with edition 2024
//~^ ERROR: this pattern relies on behavior which may change in edition 2024
assert_type_eq(x, 0u32);
assert_type_eq(y, 0u32);
}

View file

@ -1,4 +1,4 @@
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:25:13
|
LL | let Foo(mut x) = &Foo(0);
@ -16,7 +16,7 @@ help: make the implied reference pattern explicit
LL | let &Foo(mut x) = &Foo(0);
| +
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:30:13
|
LL | let Foo(mut x) = &mut Foo(0);
@ -29,7 +29,7 @@ help: make the implied reference pattern explicit
LL | let &mut Foo(mut x) = &mut Foo(0);
| ++++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:35:13
|
LL | let Foo(ref x) = &Foo(0);
@ -42,7 +42,7 @@ help: make the implied reference pattern explicit
LL | let &Foo(ref x) = &Foo(0);
| +
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:40:13
|
LL | let Foo(ref x) = &mut Foo(0);
@ -55,7 +55,7 @@ help: make the implied reference pattern explicit
LL | let &mut Foo(ref x) = &mut Foo(0);
| ++++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:57:13
|
LL | let Foo(&x) = &Foo(&0);
@ -68,7 +68,7 @@ help: make the implied reference pattern explicit
LL | let &Foo(&x) = &Foo(&0);
| +
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:62:13
|
LL | let Foo(&mut x) = &Foo(&mut 0);
@ -81,7 +81,7 @@ help: make the implied reference pattern explicit
LL | let &Foo(&mut x) = &Foo(&mut 0);
| +
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:67:13
|
LL | let Foo(&x) = &mut Foo(&0);
@ -94,7 +94,7 @@ help: make the implied reference pattern explicit
LL | let &mut Foo(&x) = &mut Foo(&0);
| ++++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:72:13
|
LL | let Foo(&mut x) = &mut Foo(&mut 0);
@ -107,7 +107,7 @@ help: make the implied reference pattern explicit
LL | let &mut Foo(&mut x) = &mut Foo(&mut 0);
| ++++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:81:17
|
LL | if let Some(&x) = &&&&&Some(&0u8) {
@ -120,7 +120,7 @@ help: make the implied reference patterns explicit
LL | if let &&&&&Some(&x) = &&&&&Some(&0u8) {
| +++++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:87:17
|
LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) {
@ -133,7 +133,7 @@ help: make the implied reference patterns explicit
LL | if let &&&&&Some(&mut x) = &&&&&Some(&mut 0u8) {
| +++++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:93:17
|
LL | if let Some(&x) = &&&&&mut Some(&0u8) {
@ -146,7 +146,7 @@ help: make the implied reference patterns explicit
LL | if let &&&&&mut Some(&x) = &&&&&mut Some(&0u8) {
| ++++++++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:99:17
|
LL | if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) {
@ -159,7 +159,7 @@ 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))) {
| ++++ ++++ +++++++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:111:21
|
LL | let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 };
@ -172,7 +172,7 @@ 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 };
| + +++ +++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:117:21
|
LL | let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 };
@ -187,7 +187,7 @@ 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 };
| + +++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:124:24
|
LL | if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } =
@ -202,7 +202,7 @@ 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) } =
| + + + +++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/migration_lint.rs:137:15
|
LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {

View file

@ -21,17 +21,17 @@ macro_rules! test_pat_on_type {
}
test_pat_on_type![(&x,): &(T,)]; //~ ERROR mismatched types
test_pat_on_type![(&x,): &(&T,)]; //~ ERROR pattern uses features incompatible with edition 2024
test_pat_on_type![(&x,): &(&T,)]; //~ ERROR this pattern relies on behavior which may change in edition 2024
test_pat_on_type![(&x,): &(&mut T,)]; //~ ERROR mismatched types
test_pat_on_type![(&mut x,): &(&T,)]; //~ ERROR mismatched types
test_pat_on_type![(&mut x,): &(&mut T,)]; //~ ERROR pattern uses features incompatible with edition 2024
test_pat_on_type![(&mut x,): &(&mut T,)]; //~ ERROR this pattern relies on behavior which may change in edition 2024
test_pat_on_type![(&x,): &&mut &(T,)]; //~ ERROR mismatched types
test_pat_on_type![Foo { f: (&x,) }: Foo]; //~ ERROR mismatched types
test_pat_on_type![Foo { f: (&x,) }: &mut Foo]; //~ ERROR mismatched types
test_pat_on_type![Foo { f: &(x,) }: &Foo]; //~ ERROR pattern uses features incompatible with edition 2024
test_pat_on_type![(mut x,): &(T,)]; //~ ERROR pattern uses features incompatible with edition 2024
test_pat_on_type![(ref x,): &(T,)]; //~ ERROR pattern uses features incompatible with edition 2024
test_pat_on_type![(ref mut x,): &mut (T,)]; //~ ERROR pattern uses features incompatible with edition 2024
test_pat_on_type![Foo { f: &(x,) }: &Foo]; //~ ERROR this pattern relies on behavior which may change in edition 2024
test_pat_on_type![(mut x,): &(T,)]; //~ ERROR this pattern relies on behavior which may change in edition 2024
test_pat_on_type![(ref x,): &(T,)]; //~ ERROR this pattern relies on behavior which may change in edition 2024
test_pat_on_type![(ref mut x,): &mut (T,)]; //~ ERROR this pattern relies on behavior which may change in edition 2024
fn get<X>() -> X {
unimplemented!()
@ -40,6 +40,6 @@ fn get<X>() -> X {
// Make sure this works even when the underlying type is inferred. This test passes on rust stable.
fn infer<X: Copy>() -> X {
match &get() {
(&x,) => x, //~ ERROR pattern uses features incompatible with edition 2024
(&x,) => x, //~ ERROR this pattern relies on behavior which may change in edition 2024
}
}

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: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:24:20
|
LL | test_pat_on_type![(&x,): &(&T,)];
@ -110,7 +110,7 @@ help: make the implied reference pattern explicit
LL | test_pat_on_type![&(&x,): &(&T,)];
| +
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:27:20
|
LL | test_pat_on_type![(&mut x,): &(&mut T,)];
@ -121,7 +121,7 @@ help: make the implied reference pattern explicit
LL | test_pat_on_type![&(&mut x,): &(&mut T,)];
| +
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:31:28
|
LL | test_pat_on_type![Foo { f: &(x,) }: &Foo];
@ -132,7 +132,7 @@ help: make the implied reference pattern explicit
LL | test_pat_on_type![&Foo { f: &(x,) }: &Foo];
| +
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:32:20
|
LL | test_pat_on_type![(mut x,): &(T,)];
@ -143,7 +143,7 @@ help: make the implied reference pattern explicit
LL | test_pat_on_type![&(mut x,): &(T,)];
| +
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:33:20
|
LL | test_pat_on_type![(ref x,): &(T,)];
@ -154,7 +154,7 @@ help: make the implied reference pattern explicit
LL | test_pat_on_type![&(ref x,): &(T,)];
| +
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:34:20
|
LL | test_pat_on_type![(ref mut x,): &mut (T,)];
@ -165,7 +165,7 @@ help: make the implied reference pattern explicit
LL | test_pat_on_type![&mut (ref mut x,): &mut (T,)];
| ++++
error: pattern uses features incompatible with edition 2024
error: this pattern relies on behavior which may change in edition 2024
--> $DIR/min_match_ergonomics_fail.rs:43:10
|
LL | (&x,) => x,