Skip to content

Commit 6068478

Browse files
committed
Add if let test
1 parent 14ca950 commit 6068478

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

src/test/ui/suggestions/match-ergonomics.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,5 @@ fn main() {
3737
v => {},
3838
_ => {},
3939
}
40+
if let [&v] = &x[..] {} //~ ERROR mismatched types
4041
}

src/test/ui/suggestions/match-ergonomics.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,19 @@ help: you can rely on match ergonomics and remove the explicit borrow
3535
LL | v => {},
3636
| ^
3737

38-
error: aborting due to 4 previous errors
38+
error[E0308]: mismatched types
39+
--> $DIR/match-ergonomics.rs:40:13
40+
|
41+
LL | if let [&v] = &x[..] {}
42+
| ^^
43+
| |
44+
| expected i32, found reference
45+
| help: you can probably remove the explicit borrow: `v`
46+
|
47+
= note: expected type `i32`
48+
found type `&_`
49+
50+
error: aborting due to 5 previous errors
3951

4052
Some errors have detailed explanations: E0308, E0529.
4153
For more information about an error, try `rustc --explain E0308`.

0 commit comments

Comments
 (0)