From 218caa410aa38c29984be31a5229b9fa717560ee Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:19:13 +0200 Subject: Merging upstream version 1.68.2+dfsg1. Signed-off-by: Daniel Baumann --- .../pattern-struct-with-slice-vec-field.rs | 35 ++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 tests/ui/suggestions/pattern-struct-with-slice-vec-field.rs (limited to 'tests/ui/suggestions/pattern-struct-with-slice-vec-field.rs') diff --git a/tests/ui/suggestions/pattern-struct-with-slice-vec-field.rs b/tests/ui/suggestions/pattern-struct-with-slice-vec-field.rs new file mode 100644 index 000000000..5b223a91f --- /dev/null +++ b/tests/ui/suggestions/pattern-struct-with-slice-vec-field.rs @@ -0,0 +1,35 @@ +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] } => {} + //~^ ERROR expected an array or slice, found `Vec + _ => {} + } +} + +fn bar(bar: &Bar) { + match bar { + Bar { v: [1, 2] } => {} + //~^ ERROR expected an array or slice, found `Vec + _ => {} + } +} + +fn main() {} -- cgit v1.2.3