diff --git a/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.rs b/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.rs index 1a9fc2f0050a7..5b223a91f508f 100644 --- a/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.rs +++ b/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.rs @@ -1,7 +1,21 @@ +use std::ops::Deref; + struct Foo { v: Vec, } +struct Bar { + v: Vec, +} + +impl Deref for Bar { + type Target = Vec; + + fn deref(&self) -> &Self::Target { + &self.v + } +} + fn f(foo: &Foo) { match foo { Foo { v: [1, 2] } => {} @@ -10,4 +24,12 @@ fn f(foo: &Foo) { } } +fn bar(bar: &Bar) { + match bar { + Bar { v: [1, 2] } => {} + //~^ ERROR expected an array or slice, found `Vec + _ => {} + } +} + fn main() {} diff --git a/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.stderr b/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.stderr index cb408d38fd276..5b48a8b18a514 100644 --- a/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.stderr +++ b/src/test/ui/suggestions/pattern-struct-with-slice-vec-field.stderr @@ -1,9 +1,15 @@ error[E0529]: expected an array or slice, found `Vec` - --> $DIR/pattern-struct-with-slice-vec-field.rs:7:18 + --> $DIR/pattern-struct-with-slice-vec-field.rs:21:18 | LL | Foo { v: [1, 2] } => {} | ^^^^^^ pattern cannot match with input type `Vec` -error: aborting due to previous error +error[E0529]: expected an array or slice, found `Vec` + --> $DIR/pattern-struct-with-slice-vec-field.rs:29:18 + | +LL | Bar { v: [1, 2] } => {} + | ^^^^^^ pattern cannot match with input type `Vec` + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0529`.