Skip to content

Commit 2ef0a8f

Browse files
committedOct 7, 2024
Change error message
1 parent 4aaada4 commit 2ef0a8f

File tree

6 files changed

+57
-58
lines changed

6 files changed

+57
-58
lines changed
 

‎compiler/rustc_mir_build/messages.ftl

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

‎compiler/rustc_mir_build/src/thir/pattern/mod.rs

+3-4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ use tracing::{debug, instrument};
2525

2626
pub(crate) use self::check_match::check_match;
2727
use crate::errors::*;
28+
use crate::fluent_generated as fluent;
2829
use crate::thir::util::UserAnnotatedTyHelpers;
2930

3031
struct PatCtxt<'a, 'tcx> {
@@ -58,10 +59,8 @@ pub(super) fn pat_from_hir<'a, 'tcx>(
5859
debug!("pat_from_hir({:?}) = {:?}", pat, result);
5960
if let Some(sugg) = pcx.rust_2024_migration_suggestion {
6061
if sugg.is_hard_error {
61-
let mut err = tcx.dcx().struct_span_err(
62-
pat.span,
63-
"patterns are not allowed to reset the default binding mode in rust 2024",
64-
);
62+
let mut err =
63+
tcx.dcx().struct_span_err(pat.span, fluent::mir_build_rust_2024_incompatible_pat);
6564
err.subdiagnostic(sugg);
6665
err.emit();
6766
} else {

‎tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.fixed

+15-15
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ fn main() {
2323
assert_type_eq(x, &mut 0u8);
2424

2525
let &Foo(mut x) = &Foo(0);
26-
//~^ ERROR: the semantics of this pattern will change in edition 2024
26+
//~^ ERROR: patterns are not allowed to reset the default binding mode
2727
//~| WARN: this changes meaning in Rust 2024
2828
assert_type_eq(x, 0u8);
2929

3030
let &mut Foo(mut x) = &mut Foo(0);
31-
//~^ ERROR: the semantics of this pattern will change in edition 2024
31+
//~^ ERROR: patterns are not allowed to reset the default binding mode
3232
//~| WARN: this changes meaning in Rust 2024
3333
assert_type_eq(x, 0u8);
3434

3535
let &Foo(ref x) = &Foo(0);
36-
//~^ ERROR: the semantics of this pattern will change in edition 2024
36+
//~^ ERROR: patterns are not allowed to reset the default binding mode
3737
//~| WARN: this changes meaning in Rust 2024
3838
assert_type_eq(x, &0u8);
3939

4040
let &mut Foo(ref x) = &mut Foo(0);
41-
//~^ ERROR: the semantics of this pattern will change in edition 2024
41+
//~^ ERROR: patterns are not allowed to reset the default binding mode
4242
//~| WARN: this changes meaning in Rust 2024
4343
assert_type_eq(x, &0u8);
4444

@@ -55,22 +55,22 @@ fn main() {
5555
assert_type_eq(x, &0u8);
5656

5757
let &Foo(&x) = &Foo(&0);
58-
//~^ ERROR: the semantics of this pattern will change in edition 2024
58+
//~^ ERROR: patterns are not allowed to reset the default binding mode
5959
//~| WARN: this changes meaning in Rust 2024
6060
assert_type_eq(x, 0u8);
6161

6262
let &Foo(&mut x) = &Foo(&mut 0);
63-
//~^ ERROR: the semantics of this pattern will change in edition 2024
63+
//~^ ERROR: patterns are not allowed to reset the default binding mode
6464
//~| WARN: this changes meaning in Rust 2024
6565
assert_type_eq(x, 0u8);
6666

6767
let &mut Foo(&x) = &mut Foo(&0);
68-
//~^ ERROR: the semantics of this pattern will change in edition 2024
68+
//~^ ERROR: patterns are not allowed to reset the default binding mode
6969
//~| WARN: this changes meaning in Rust 2024
7070
assert_type_eq(x, 0u8);
7171

7272
let &mut Foo(&mut x) = &mut Foo(&mut 0);
73-
//~^ ERROR: the semantics of this pattern will change in edition 2024
73+
//~^ ERROR: patterns are not allowed to reset the default binding mode
7474
//~| WARN: this changes meaning in Rust 2024
7575
assert_type_eq(x, 0u8);
7676

@@ -79,25 +79,25 @@ fn main() {
7979
}
8080

8181
if let &&&&&Some(&x) = &&&&&Some(&0u8) {
82-
//~^ ERROR: the semantics of this pattern will change in edition 2024
82+
//~^ ERROR: patterns are not allowed to reset the default binding mode
8383
//~| WARN: this changes meaning in Rust 2024
8484
assert_type_eq(x, 0u8);
8585
}
8686

8787
if let &&&&&Some(&mut x) = &&&&&Some(&mut 0u8) {
88-
//~^ ERROR: the semantics of this pattern will change in edition 2024
88+
//~^ ERROR: patterns are not allowed to reset the default binding mode
8989
//~| WARN: this changes meaning in Rust 2024
9090
assert_type_eq(x, 0u8);
9191
}
9292

9393
if let &&&&&mut Some(&x) = &&&&&mut Some(&0u8) {
94-
//~^ ERROR: the semantics of this pattern will change in edition 2024
94+
//~^ ERROR: patterns are not allowed to reset the default binding mode
9595
//~| WARN: this changes meaning in Rust 2024
9696
assert_type_eq(x, 0u8);
9797
}
9898

9999
if let &mut Some(&mut Some(&mut Some(ref mut x))) = &mut Some(&mut Some(&mut Some(0u8))) {
100-
//~^ ERROR: the semantics of this pattern will change in edition 2024
100+
//~^ ERROR: patterns are not allowed to reset the default binding mode
101101
//~| WARN: this changes meaning in Rust 2024
102102
assert_type_eq(x, &mut 0u8);
103103
}
@@ -109,20 +109,20 @@ fn main() {
109109
}
110110

111111
let &Struct { ref a, mut b, ref c } = &Struct { a: 0, b: 0, c: 0 };
112-
//~^ ERROR: the semantics of this pattern will change in edition 2024
112+
//~^ ERROR: patterns are not allowed to reset the default binding mode
113113
//~| WARN: this changes meaning in Rust 2024
114114
assert_type_eq(a, &0u32);
115115
assert_type_eq(b, 0u32);
116116

117117
let &Struct { a: &a, ref b, ref c } = &Struct { a: &0, b: &0, c: &0 };
118-
//~^ ERROR: the semantics of this pattern will change in edition 2024
118+
//~^ ERROR: patterns are not allowed to reset the default binding mode
119119
//~| WARN: this changes meaning in Rust 2024
120120
assert_type_eq(a, 0u32);
121121
assert_type_eq(b, &&0u32);
122122
assert_type_eq(c, &&0u32);
123123

124124
if let &Struct { a: &Some(a), b: &Some(&b), c: &Some(ref c) } =
125-
//~^ ERROR: the semantics of this pattern will change in edition 2024
125+
//~^ ERROR: patterns are not allowed to reset the default binding mode
126126
//~| WARN: this changes meaning in Rust 2024
127127
&(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) })
128128
{

‎tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.rs

+15-15
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,22 @@ fn main() {
2323
assert_type_eq(x, &mut 0u8);
2424

2525
let Foo(mut x) = &Foo(0);
26-
//~^ ERROR: the semantics of this pattern will change in edition 2024
26+
//~^ ERROR: patterns are not allowed to reset the default binding mode
2727
//~| WARN: this changes meaning in Rust 2024
2828
assert_type_eq(x, 0u8);
2929

3030
let Foo(mut x) = &mut Foo(0);
31-
//~^ ERROR: the semantics of this pattern will change in edition 2024
31+
//~^ ERROR: patterns are not allowed to reset the default binding mode
3232
//~| WARN: this changes meaning in Rust 2024
3333
assert_type_eq(x, 0u8);
3434

3535
let Foo(ref x) = &Foo(0);
36-
//~^ ERROR: the semantics of this pattern will change in edition 2024
36+
//~^ ERROR: patterns are not allowed to reset the default binding mode
3737
//~| WARN: this changes meaning in Rust 2024
3838
assert_type_eq(x, &0u8);
3939

4040
let Foo(ref x) = &mut Foo(0);
41-
//~^ ERROR: the semantics of this pattern will change in edition 2024
41+
//~^ ERROR: patterns are not allowed to reset the default binding mode
4242
//~| WARN: this changes meaning in Rust 2024
4343
assert_type_eq(x, &0u8);
4444

@@ -55,22 +55,22 @@ fn main() {
5555
assert_type_eq(x, &0u8);
5656

5757
let Foo(&x) = &Foo(&0);
58-
//~^ ERROR: the semantics of this pattern will change in edition 2024
58+
//~^ ERROR: patterns are not allowed to reset the default binding mode
5959
//~| WARN: this changes meaning in Rust 2024
6060
assert_type_eq(x, 0u8);
6161

6262
let Foo(&mut x) = &Foo(&mut 0);
63-
//~^ ERROR: the semantics of this pattern will change in edition 2024
63+
//~^ ERROR: patterns are not allowed to reset the default binding mode
6464
//~| WARN: this changes meaning in Rust 2024
6565
assert_type_eq(x, 0u8);
6666

6767
let Foo(&x) = &mut Foo(&0);
68-
//~^ ERROR: the semantics of this pattern will change in edition 2024
68+
//~^ ERROR: patterns are not allowed to reset the default binding mode
6969
//~| WARN: this changes meaning in Rust 2024
7070
assert_type_eq(x, 0u8);
7171

7272
let Foo(&mut x) = &mut Foo(&mut 0);
73-
//~^ ERROR: the semantics of this pattern will change in edition 2024
73+
//~^ ERROR: patterns are not allowed to reset the default binding mode
7474
//~| WARN: this changes meaning in Rust 2024
7575
assert_type_eq(x, 0u8);
7676

@@ -79,25 +79,25 @@ fn main() {
7979
}
8080

8181
if let Some(&x) = &&&&&Some(&0u8) {
82-
//~^ ERROR: the semantics of this pattern will change in edition 2024
82+
//~^ ERROR: patterns are not allowed to reset the default binding mode
8383
//~| WARN: this changes meaning in Rust 2024
8484
assert_type_eq(x, 0u8);
8585
}
8686

8787
if let Some(&mut x) = &&&&&Some(&mut 0u8) {
88-
//~^ ERROR: the semantics of this pattern will change in edition 2024
88+
//~^ ERROR: patterns are not allowed to reset the default binding mode
8989
//~| WARN: this changes meaning in Rust 2024
9090
assert_type_eq(x, 0u8);
9191
}
9292

9393
if let Some(&x) = &&&&&mut Some(&0u8) {
94-
//~^ ERROR: the semantics of this pattern will change in edition 2024
94+
//~^ ERROR: patterns are not allowed to reset the default binding mode
9595
//~| WARN: this changes meaning in Rust 2024
9696
assert_type_eq(x, 0u8);
9797
}
9898

9999
if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) {
100-
//~^ ERROR: the semantics of this pattern will change in edition 2024
100+
//~^ ERROR: patterns are not allowed to reset the default binding mode
101101
//~| WARN: this changes meaning in Rust 2024
102102
assert_type_eq(x, &mut 0u8);
103103
}
@@ -109,20 +109,20 @@ fn main() {
109109
}
110110

111111
let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 };
112-
//~^ ERROR: the semantics of this pattern will change in edition 2024
112+
//~^ ERROR: patterns are not allowed to reset the default binding mode
113113
//~| WARN: this changes meaning in Rust 2024
114114
assert_type_eq(a, &0u32);
115115
assert_type_eq(b, 0u32);
116116

117117
let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 };
118-
//~^ ERROR: the semantics of this pattern will change in edition 2024
118+
//~^ ERROR: patterns are not allowed to reset the default binding mode
119119
//~| WARN: this changes meaning in Rust 2024
120120
assert_type_eq(a, 0u32);
121121
assert_type_eq(b, &&0u32);
122122
assert_type_eq(c, &&0u32);
123123

124124
if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } =
125-
//~^ ERROR: the semantics of this pattern will change in edition 2024
125+
//~^ ERROR: patterns are not allowed to reset the default binding mode
126126
//~| WARN: this changes meaning in Rust 2024
127127
&(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) })
128128
{

‎tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr

+16-16
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: the semantics of this pattern will change in edition 2024
1+
error: patterns are not allowed to reset the default binding mode in edition 2024
22
--> $DIR/migration_lint.rs:25:9
33
|
44
LL | let Foo(mut x) = &Foo(0);
@@ -14,7 +14,7 @@ note: the lint level is defined here
1414
LL | #![deny(rust_2024_incompatible_pat)]
1515
| ^^^^^^^^^^^^^^^^^^^^^^^^^^
1616

17-
error: the semantics of this pattern will change in edition 2024
17+
error: patterns are not allowed to reset the default binding mode in edition 2024
1818
--> $DIR/migration_lint.rs:30:9
1919
|
2020
LL | let Foo(mut x) = &mut Foo(0);
@@ -25,7 +25,7 @@ LL | let Foo(mut x) = &mut Foo(0);
2525
= warning: this changes meaning in Rust 2024
2626
= note: for more information, see 123076
2727

28-
error: the semantics of this pattern will change in edition 2024
28+
error: patterns are not allowed to reset the default binding mode in edition 2024
2929
--> $DIR/migration_lint.rs:35:9
3030
|
3131
LL | let Foo(ref x) = &Foo(0);
@@ -36,7 +36,7 @@ LL | let Foo(ref x) = &Foo(0);
3636
= warning: this changes meaning in Rust 2024
3737
= note: for more information, see 123076
3838

39-
error: the semantics of this pattern will change in edition 2024
39+
error: patterns are not allowed to reset the default binding mode in edition 2024
4040
--> $DIR/migration_lint.rs:40:9
4141
|
4242
LL | let Foo(ref x) = &mut Foo(0);
@@ -47,7 +47,7 @@ LL | let Foo(ref x) = &mut Foo(0);
4747
= warning: this changes meaning in Rust 2024
4848
= note: for more information, see 123076
4949

50-
error: the semantics of this pattern will change in edition 2024
50+
error: patterns are not allowed to reset the default binding mode in edition 2024
5151
--> $DIR/migration_lint.rs:57:9
5252
|
5353
LL | let Foo(&x) = &Foo(&0);
@@ -58,7 +58,7 @@ LL | let Foo(&x) = &Foo(&0);
5858
= warning: this changes meaning in Rust 2024
5959
= note: for more information, see 123076
6060

61-
error: the semantics of this pattern will change in edition 2024
61+
error: patterns are not allowed to reset the default binding mode in edition 2024
6262
--> $DIR/migration_lint.rs:62:9
6363
|
6464
LL | let Foo(&mut x) = &Foo(&mut 0);
@@ -69,7 +69,7 @@ LL | let Foo(&mut x) = &Foo(&mut 0);
6969
= warning: this changes meaning in Rust 2024
7070
= note: for more information, see 123076
7171

72-
error: the semantics of this pattern will change in edition 2024
72+
error: patterns are not allowed to reset the default binding mode in edition 2024
7373
--> $DIR/migration_lint.rs:67:9
7474
|
7575
LL | let Foo(&x) = &mut Foo(&0);
@@ -80,7 +80,7 @@ LL | let Foo(&x) = &mut Foo(&0);
8080
= warning: this changes meaning in Rust 2024
8181
= note: for more information, see 123076
8282

83-
error: the semantics of this pattern will change in edition 2024
83+
error: patterns are not allowed to reset the default binding mode in edition 2024
8484
--> $DIR/migration_lint.rs:72:9
8585
|
8686
LL | let Foo(&mut x) = &mut Foo(&mut 0);
@@ -91,7 +91,7 @@ LL | let Foo(&mut x) = &mut Foo(&mut 0);
9191
= warning: this changes meaning in Rust 2024
9292
= note: for more information, see 123076
9393

94-
error: the semantics of this pattern will change in edition 2024
94+
error: patterns are not allowed to reset the default binding mode in edition 2024
9595
--> $DIR/migration_lint.rs:81:12
9696
|
9797
LL | if let Some(&x) = &&&&&Some(&0u8) {
@@ -102,7 +102,7 @@ LL | if let Some(&x) = &&&&&Some(&0u8) {
102102
= warning: this changes meaning in Rust 2024
103103
= note: for more information, see 123076
104104

105-
error: the semantics of this pattern will change in edition 2024
105+
error: patterns are not allowed to reset the default binding mode in edition 2024
106106
--> $DIR/migration_lint.rs:87:12
107107
|
108108
LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) {
@@ -113,7 +113,7 @@ LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) {
113113
= warning: this changes meaning in Rust 2024
114114
= note: for more information, see 123076
115115

116-
error: the semantics of this pattern will change in edition 2024
116+
error: patterns are not allowed to reset the default binding mode in edition 2024
117117
--> $DIR/migration_lint.rs:93:12
118118
|
119119
LL | if let Some(&x) = &&&&&mut Some(&0u8) {
@@ -124,7 +124,7 @@ LL | if let Some(&x) = &&&&&mut Some(&0u8) {
124124
= warning: this changes meaning in Rust 2024
125125
= note: for more information, see 123076
126126

127-
error: the semantics of this pattern will change in edition 2024
127+
error: patterns are not allowed to reset the default binding mode in edition 2024
128128
--> $DIR/migration_lint.rs:99:12
129129
|
130130
LL | if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) {
@@ -137,7 +137,7 @@ help: desugar the match ergonomics
137137
LL | if let &mut Some(&mut Some(&mut Some(ref mut x))) = &mut Some(&mut Some(&mut Some(0u8))) {
138138
| ++++ ++++ +++++++
139139

140-
error: the semantics of this pattern will change in edition 2024
140+
error: patterns are not allowed to reset the default binding mode in edition 2024
141141
--> $DIR/migration_lint.rs:111:9
142142
|
143143
LL | let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 };
@@ -150,7 +150,7 @@ help: desugar the match ergonomics
150150
LL | let &Struct { ref a, mut b, ref c } = &Struct { a: 0, b: 0, c: 0 };
151151
| + +++ +++
152152

153-
error: the semantics of this pattern will change in edition 2024
153+
error: patterns are not allowed to reset the default binding mode in edition 2024
154154
--> $DIR/migration_lint.rs:117:9
155155
|
156156
LL | let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 };
@@ -163,7 +163,7 @@ help: desugar the match ergonomics
163163
LL | let &Struct { a: &a, ref b, ref c } = &Struct { a: &0, b: &0, c: &0 };
164164
| + +++
165165

166-
error: the semantics of this pattern will change in edition 2024
166+
error: patterns are not allowed to reset the default binding mode in edition 2024
167167
--> $DIR/migration_lint.rs:124:12
168168
|
169169
LL | if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } =
@@ -176,7 +176,7 @@ help: desugar the match ergonomics
176176
LL | if let &Struct { a: &Some(a), b: &Some(&b), c: &Some(ref c) } =
177177
| + + + +++
178178

179-
error: patterns are not allowed to reset the default binding mode in rust 2024
179+
error: patterns are not allowed to reset the default binding mode in edition 2024
180180
--> $DIR/migration_lint.rs:137:9
181181
|
182182
LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {

‎tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr

+7-7
Original file line numberDiff line numberDiff line change
@@ -99,55 +99,55 @@ LL - test_pat_on_type![Foo { f: (&x,) }: &mut Foo];
9999
LL + test_pat_on_type![Foo { f: (x,) }: &mut Foo];
100100
|
101101

102-
error: patterns are not allowed to reset the default binding mode in rust 2024
102+
error: patterns are not allowed to reset the default binding mode in edition 2024
103103
--> $DIR/min_match_ergonomics_fail.rs:25:19
104104
|
105105
LL | test_pat_on_type![(&x,): &(&T,)];
106106
| -^^^^
107107
| |
108108
| help: desugar the match ergonomics: `&`
109109

110-
error: patterns are not allowed to reset the default binding mode in rust 2024
110+
error: patterns are not allowed to reset the default binding mode in edition 2024
111111
--> $DIR/min_match_ergonomics_fail.rs:28:19
112112
|
113113
LL | test_pat_on_type![(&mut x,): &(&mut T,)];
114114
| -^^^^^^^^
115115
| |
116116
| help: desugar the match ergonomics: `&`
117117

118-
error: patterns are not allowed to reset the default binding mode in rust 2024
118+
error: patterns are not allowed to reset the default binding mode in edition 2024
119119
--> $DIR/min_match_ergonomics_fail.rs:32:19
120120
|
121121
LL | test_pat_on_type![Foo { f: &(x,) }: &Foo];
122122
| -^^^^^^^^^^^^^^^
123123
| |
124124
| help: desugar the match ergonomics: `&`
125125

126-
error: patterns are not allowed to reset the default binding mode in rust 2024
126+
error: patterns are not allowed to reset the default binding mode in edition 2024
127127
--> $DIR/min_match_ergonomics_fail.rs:33:19
128128
|
129129
LL | test_pat_on_type![(mut x,): &(T,)];
130130
| -^^^^^^^
131131
| |
132132
| help: desugar the match ergonomics: `&`
133133

134-
error: patterns are not allowed to reset the default binding mode in rust 2024
134+
error: patterns are not allowed to reset the default binding mode in edition 2024
135135
--> $DIR/min_match_ergonomics_fail.rs:34:19
136136
|
137137
LL | test_pat_on_type![(ref x,): &(T,)];
138138
| -^^^^^^^
139139
| |
140140
| help: desugar the match ergonomics: `&`
141141

142-
error: patterns are not allowed to reset the default binding mode in rust 2024
142+
error: patterns are not allowed to reset the default binding mode in edition 2024
143143
--> $DIR/min_match_ergonomics_fail.rs:35:19
144144
|
145145
LL | test_pat_on_type![(ref mut x,): &mut (T,)];
146146
| -^^^^^^^^^^^
147147
| |
148148
| help: desugar the match ergonomics: `&mut`
149149

150-
error: patterns are not allowed to reset the default binding mode in rust 2024
150+
error: patterns are not allowed to reset the default binding mode in edition 2024
151151
--> $DIR/min_match_ergonomics_fail.rs:44:9
152152
|
153153
LL | (&x,) => x,

0 commit comments

Comments
 (0)
Please sign in to comment.