summaryrefslogtreecommitdiffstats
path: root/tests/ui/suggestions/pattern-struct-with-slice-vec-field.rs
blob: 5b223a91f508f1c714bb34afe55bee50ad384797 (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
32
33
34
35
use std::ops::Deref;

struct Foo {
    v: Vec<u32>,
}

struct Bar {
    v: Vec<u32>,
}

impl Deref for Bar {
    type Target = Vec<u32>;

    fn deref(&self) -> &Self::Target {
        &self.v
    }
}

fn f(foo: &Foo) {
    match foo {
        Foo { v: [1, 2] } => {}
        //~^ ERROR expected an array or slice, found `Vec<u32>
        _ => {}
    }
}

fn bar(bar: &Bar) {
    match bar {
        Bar { v: [1, 2] } => {}
        //~^ ERROR expected an array or slice, found `Vec<u32>
        _ => {}
    }
}

fn main() {}