summaryrefslogtreecommitdiffstats
path: root/src/test/ui/typeck/issue-91328.fixed
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/ui/typeck/issue-91328.fixed')
-rw-r--r--src/test/ui/typeck/issue-91328.fixed47
1 files changed, 47 insertions, 0 deletions
diff --git a/src/test/ui/typeck/issue-91328.fixed b/src/test/ui/typeck/issue-91328.fixed
new file mode 100644
index 000000000..c0384399a
--- /dev/null
+++ b/src/test/ui/typeck/issue-91328.fixed
@@ -0,0 +1,47 @@
+// Regression test for issue #91328.
+
+// run-rustfix
+
+#![allow(dead_code)]
+
+fn foo(r: Result<Vec<i32>, i32>) -> i32 {
+ match r.as_deref() {
+ //~^ HELP: consider using `as_deref` here
+ Ok([a, b]) => a + b,
+ //~^ ERROR: expected an array or slice
+ //~| NOTE: pattern cannot match with input type
+ _ => 42,
+ }
+}
+
+fn bar(o: Option<Vec<i32>>) -> i32 {
+ match o.as_deref() {
+ //~^ HELP: consider using `as_deref` here
+ Some([a, b]) => a + b,
+ //~^ ERROR: expected an array or slice
+ //~| NOTE: pattern cannot match with input type
+ _ => 42,
+ }
+}
+
+fn baz(v: Vec<i32>) -> i32 {
+ match v[..] {
+ //~^ HELP: consider slicing here
+ [a, b] => a + b,
+ //~^ ERROR: expected an array or slice
+ //~| NOTE: pattern cannot match with input type
+ _ => 42,
+ }
+}
+
+fn qux(a: &Option<Box<[i32; 2]>>) -> i32 {
+ match a.as_deref() {
+ //~^ HELP: consider using `as_deref` here
+ Some([a, b]) => a + b,
+ //~^ ERROR: expected an array or slice
+ //~| NOTE: pattern cannot match with input type
+ _ => 42,
+ }
+}
+
+fn main() {}