File tree Expand file tree Collapse file tree 3 files changed +34
-1
lines changed
tests/ui/pattern/rfc-3627-match-ergonomics-2024 Expand file tree Collapse file tree 3 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -244,4 +244,10 @@ fn main() {
244244 let &[migration_lint_macros::bind_ref!(a)] = &[0];
245245 //~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
246246 assert_type_eq(a, &0u32);
247+
248+ // Test that we use the correct span when labeling a `&` whose subpattern is from an expansion.
249+ let &[&migration_lint_macros::bind_ref!(a)] = &[&0];
250+ //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
251+ //~| WARN: this changes meaning in Rust 2024
252+ assert_type_eq(a, &0u32);
247253}
Original file line number Diff line number Diff line change @@ -244,4 +244,10 @@ fn main() {
244244 let [ migration_lint_macros:: bind_ref!( a) ] = & [ 0 ] ;
245245 //~^ ERROR: binding modifiers may only be written when the default binding mode is `move`
246246 assert_type_eq ( a, & 0u32 ) ;
247+
248+ // Test that we use the correct span when labeling a `&` whose subpattern is from an expansion.
249+ let [ & migration_lint_macros:: bind_ref!( a) ] = & [ & 0 ] ;
250+ //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024
251+ //~| WARN: this changes meaning in Rust 2024
252+ assert_type_eq ( a, & 0u32 ) ;
247253}
Original file line number Diff line number Diff line change @@ -580,5 +580,26 @@ help: make the implied reference pattern explicit
580580LL | let &[migration_lint_macros::bind_ref!(a)] = &[0];
581581 | +
582582
583- error: aborting due to 30 previous errors
583+ error: reference patterns may only be written when the default binding mode is `move` in Rust 2024
584+ --> $DIR/auxiliary/migration_lint_macros.rs:15:22
585+ |
586+ LL | ($foo:ident) => {
587+ | ______________________^
588+ LL | | ref $foo
589+ | |________________^ reference pattern not allowed under `ref` default binding mode
590+ |
591+ = warning: this changes meaning in Rust 2024
592+ = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html>
593+ note: matching on a reference type with a non-reference pattern changes the default binding mode
594+ --> $DIR/migration_lint.rs:249:9
595+ |
596+ LL | let [&migration_lint_macros::bind_ref!(a)] = &[&0];
597+ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_`
598+ help: make the implied reference pattern explicit
599+ --> $DIR/migration_lint.rs:249:9
600+ |
601+ LL | let &[&migration_lint_macros::bind_ref!(a)] = &[&0];
602+ | +
603+
604+ error: aborting due to 31 previous errors
584605
You can’t perform that action at this time.
0 commit comments