summaryrefslogtreecommitdiffstats
path: root/src/test/ui/suggestions/pattern-slice-vec.fixed
blob: f8144641f3c314823101338489efd16a7f06efc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// Regression test for #87017.

// run-rustfix

fn main() {
    fn foo() -> Vec<i32> { vec![1, 2, 3] }

    if let [_, _, _] = foo()[..] {}
    //~^ ERROR: expected an array or slice
    //~| HELP: consider slicing here

    if let [] = &foo()[..] {}
    //~^ ERROR: expected an array or slice
    //~| HELP: consider slicing here

    if let [] = foo()[..] {}
    //~^ ERROR: expected an array or slice
    //~| HELP: consider slicing here

    let v = vec![];
    match &v[..] {
    //~^ HELP: consider slicing here
        [5] => {}
        //~^ ERROR: expected an array or slice
        _ => {}
    }

    let [..] = vec![1, 2, 3][..];
    //~^ ERROR: expected an array or slice
    //~| HELP: consider slicing here
}