Skip to content

Commit b807006

Browse files
Add tests for the issue#120605
1 parent 31f9d29 commit b807006

File tree

2 files changed

+43
-0
lines changed

2 files changed

+43
-0
lines changed

tests/ui/suggestions/issue120605.rs

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
pub struct Struct {
2+
a: Vec<Struct>,
3+
}
4+
5+
impl Struct {
6+
pub fn test(&self) {
7+
if let [Struct { a: [] }] = &self.a {
8+
//~^ ERROR expected an array or slice
9+
//~| ERROR expected an array or slice
10+
println!("matches!")
11+
}
12+
13+
if let [Struct { a: [] }] = &self.a[..] {
14+
//~^ ERROR expected an array or slice
15+
println!("matches!")
16+
}
17+
}
18+
}
19+
20+
fn main() {}
+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
error[E0529]: expected an array or slice, found `Vec<Struct>`
2+
--> $DIR/issue120605.rs:7:16
3+
|
4+
LL | if let [Struct { a: [] }] = &self.a {
5+
| ^^^^^^^^^^^^^^^^^^ ------- help: consider slicing here: `&self.a[..]`
6+
| |
7+
| pattern cannot match with input type `Vec<Struct>`
8+
9+
error[E0529]: expected an array or slice, found `Vec<Struct>`
10+
--> $DIR/issue120605.rs:7:29
11+
|
12+
LL | if let [Struct { a: [] }] = &self.a {
13+
| ^^ pattern cannot match with input type `Vec<Struct>`
14+
15+
error[E0529]: expected an array or slice, found `Vec<Struct>`
16+
--> $DIR/issue120605.rs:13:29
17+
|
18+
LL | if let [Struct { a: [] }] = &self.a[..] {
19+
| ^^ pattern cannot match with input type `Vec<Struct>`
20+
21+
error: aborting due to 3 previous errors
22+
23+
For more information about this error, try `rustc --explain E0529`.

0 commit comments

Comments
 (0)