File tree 3 files changed +47
-1
lines changed
tests/ui/pattern/rfc-3627-match-ergonomics-2024 3 files changed +47
-1
lines changed Original file line number Diff line number Diff line change @@ -141,4 +141,13 @@ fn main() {
141
141
}
142
142
_ => {}
143
143
}
144
+
145
+ let &mut [&mut &[ref a]] = &mut [&mut &[0]];
146
+ //~^ ERROR: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024
147
+ //~| WARN: this changes meaning in Rust 2024
148
+ assert_type_eq(a, &0u32);
149
+
150
+ let &[&(_)] = &[&0];
151
+ //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
152
+ //~| WARN: this changes meaning in Rust 2024
144
153
}
Original file line number Diff line number Diff line change @@ -141,4 +141,13 @@ fn main() {
141
141
}
142
142
_ => { }
143
143
}
144
+
145
+ let [ & mut [ ref a] ] = & mut [ & mut & [ 0 ] ] ;
146
+ //~^ ERROR: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024
147
+ //~| WARN: this changes meaning in Rust 2024
148
+ assert_type_eq ( a, & 0u32 ) ;
149
+
150
+ let [ & ( _) ] = & [ & 0 ] ;
151
+ //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
152
+ //~| WARN: this changes meaning in Rust 2024
144
153
}
Original file line number Diff line number Diff line change @@ -217,5 +217,33 @@ help: make the implied reference pattern explicit
217
217
LL | &(Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
218
218
| +
219
219
220
- error: aborting due to 16 previous errors
220
+ error: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024
221
+ --> $DIR/migration_lint.rs:145:10
222
+ |
223
+ LL | let [&mut [ref a]] = &mut [&mut &[0]];
224
+ | ^^^^ ^^^ default binding mode is `ref`
225
+ | |
226
+ | default binding mode is `ref mut`
227
+ |
228
+ = warning: this changes meaning in Rust 2024
229
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
230
+ help: make the implied reference patterns explicit
231
+ |
232
+ LL | let &mut [&mut &[ref a]] = &mut [&mut &[0]];
233
+ | ++++ +
234
+
235
+ error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
236
+ --> $DIR/migration_lint.rs:150:10
237
+ |
238
+ LL | let [&(_)] = &[&0];
239
+ | ^^ default binding mode is `ref`
240
+ |
241
+ = warning: this changes meaning in Rust 2024
242
+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
243
+ help: make the implied reference pattern explicit
244
+ |
245
+ LL | let &[&(_)] = &[&0];
246
+ | +
247
+
248
+ error: aborting due to 18 previous errors
221
249
You can’t perform that action at this time.
0 commit comments