Skip to content

Commit 9202001

Browse files
committed
add tests for label formatting
1 parent bbe40ac commit 9202001

File tree

3 files changed

+47
-1
lines changed

3 files changed

+47
-1
lines changed

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,13 @@ fn main() {
141141
}
142142
_ => {}
143143
}
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
144153
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,4 +141,13 @@ fn main() {
141141
}
142142
_ => {}
143143
}
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
144153
}

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,33 @@ help: make the implied reference pattern explicit
217217
LL | &(Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => {
218218
| +
219219

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
221249

0 commit comments

Comments
 (0)