Skip to content

Clarify the match ergonomics 2024 migration lint's output #134394

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Improve the pattern migration 2024 migration lint's message
  • Loading branch information
dianne committed Dec 17, 2024
commit 77e9051e22c89585f0e96f3476edbe664a80ccc0
2 changes: 1 addition & 1 deletion compiler/rustc_mir_build/messages.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);
}
Expand All @@ -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) })
{
Expand All @@ -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);
}
Expand Down
32 changes: 16 additions & 16 deletions tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -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);

Expand All @@ -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);
}
Expand All @@ -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) })
{
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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))) {
Expand All @@ -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 };
Expand All @@ -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 };
Expand All @@ -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) } =
Expand All @@ -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)) => {
Expand Down
Loading