File tree Expand file tree Collapse file tree 2 files changed +81
-0
lines changed Expand file tree Collapse file tree 2 files changed +81
-0
lines changed Original file line number Diff line number Diff line change 1+ fn main ( ) {
2+ let x = vec ! [ 1i32 ] ;
3+ match & x[ ..] {
4+ [ & v] => { } , //~ ERROR mismatched types
5+ _ => { } ,
6+ }
7+ match x {
8+ [ & v] => { } , //~ ERROR expected an array or slice
9+ _ => { } ,
10+ }
11+ match & x[ ..] {
12+ [ v] => { } ,
13+ _ => { } ,
14+ }
15+ match & x[ ..] {
16+ & [ v] => { } ,
17+ _ => { } ,
18+ }
19+ match x {
20+ [ v] => { } , //~ ERROR expected an array or slice
21+ _ => { } ,
22+ }
23+ let y = 1i32 ;
24+ match & y {
25+ & v => { } ,
26+ _ => { } ,
27+ }
28+ match y {
29+ & v => { } , //~ ERROR mismatched types
30+ _ => { } ,
31+ }
32+ match & y {
33+ v => { } ,
34+ _ => { } ,
35+ }
36+ match y {
37+ v => { } ,
38+ _ => { } ,
39+ }
40+ }
Original file line number Diff line number Diff line change 1+ error[E0308]: mismatched types
2+ --> $DIR/match-ergonomics.rs:4:10
3+ |
4+ LL | [&v] => {},
5+ | ^^
6+ | |
7+ | expected i32, found reference
8+ | help: you can probaly remove the explicit borrow: `v`
9+ |
10+ = note: expected type `i32`
11+ found type `&_`
12+
13+ error[E0529]: expected an array or slice, found `std::vec::Vec<i32>`
14+ --> $DIR/match-ergonomics.rs:8:9
15+ |
16+ LL | [&v] => {},
17+ | ^^^^ pattern cannot match with input type `std::vec::Vec<i32>`
18+
19+ error[E0529]: expected an array or slice, found `std::vec::Vec<i32>`
20+ --> $DIR/match-ergonomics.rs:20:9
21+ |
22+ LL | [v] => {},
23+ | ^^^ pattern cannot match with input type `std::vec::Vec<i32>`
24+
25+ error[E0308]: mismatched types
26+ --> $DIR/match-ergonomics.rs:29:9
27+ |
28+ LL | &v => {},
29+ | ^^ expected i32, found reference
30+ |
31+ = note: expected type `i32`
32+ found type `&_`
33+ help: you can rely on match ergonomics and remove the explicit borrow
34+ |
35+ LL | v => {},
36+ | ^
37+
38+ error: aborting due to 4 previous errors
39+
40+ Some errors have detailed explanations: E0308, E0529.
41+ For more information about an error, try `rustc --explain E0308`.
You can’t perform that action at this time.
0 commit comments