diff --git a/tests/ui/array-slice-vec/infer_array_len.rs b/tests/ui/array-slice-vec/infer_array_len.rs
index 22fe7cb8838..547c1f5727f 100644
--- a/tests/ui/array-slice-vec/infer_array_len.rs
+++ b/tests/ui/array-slice-vec/infer_array_len.rs
@@ -1,4 +1,4 @@
-// see issue #70529
+// check-pass
struct A;
impl From for [u8; 2] {
@@ -13,9 +13,7 @@ impl From for [u8; 3] {
}
}
-
fn main() {
let a = A;
let [_, _] = a.into();
- //~^ ERROR type annotations needed
}
diff --git a/tests/ui/array-slice-vec/infer_array_len.stderr b/tests/ui/array-slice-vec/infer_array_len.stderr
deleted file mode 100644
index c2a509a1963..00000000000
--- a/tests/ui/array-slice-vec/infer_array_len.stderr
+++ /dev/null
@@ -1,14 +0,0 @@
-error[E0282]: type annotations needed
- --> $DIR/infer_array_len.rs:19:9
- |
-LL | let [_, _] = a.into();
- | ^^^^^^
- |
-help: consider giving this pattern a type
- |
-LL | let [_, _]: /* Type */ = a.into();
- | ++++++++++++
-
-error: aborting due to previous error
-
-For more information about this error, try `rustc --explain E0282`.
diff --git a/tests/ui/array-slice-vec/slice-pat-type-mismatches.rs b/tests/ui/array-slice-vec/slice-pat-type-mismatches.rs
index 521b898e7fe..310c49701ed 100644
--- a/tests/ui/array-slice-vec/slice-pat-type-mismatches.rs
+++ b/tests/ui/array-slice-vec/slice-pat-type-mismatches.rs
@@ -2,7 +2,7 @@ fn main() {
match "foo".to_string() {
['f', 'o', ..] => {}
//~^ ERROR expected an array or slice, found `String`
- _ => { }
+ _ => {}
};
// Note that this one works with default binding modes.
@@ -15,7 +15,7 @@ fn main() {
};
match [0, 1, 2] {
- [0] => {}, //~ ERROR pattern requires
+ [0] => {} //~ ERROR pattern requires
[0, 1, x @ ..] => {
let a: [_; 1] = x;
@@ -23,14 +23,16 @@ fn main() {
[0, 1, 2, 3, x @ ..] => {} //~ ERROR pattern requires
};
- match does_not_exist { //~ ERROR cannot find value `does_not_exist` in this scope
- [] => {}
+ match does_not_exist {
+ //~^ ERROR cannot find value `does_not_exist` in this scope
+ [] => {} // ERROR cannot find value `does_not_exist` in this scope
};
}
fn another_fn_to_avoid_suppression() {
- match Default::default()
+ match Default
+ //~^ ERROR expected value, found trait
{
- [] => {} //~ ERROR type annotations needed
+ [] => {}
};
}
diff --git a/tests/ui/array-slice-vec/slice-pat-type-mismatches.stderr b/tests/ui/array-slice-vec/slice-pat-type-mismatches.stderr
index 70a4cbebeee..6218bffd503 100644
--- a/tests/ui/array-slice-vec/slice-pat-type-mismatches.stderr
+++ b/tests/ui/array-slice-vec/slice-pat-type-mismatches.stderr
@@ -4,6 +4,12 @@ error[E0425]: cannot find value `does_not_exist` in this scope
LL | match does_not_exist {
| ^^^^^^^^^^^^^^ not found in this scope
+error[E0423]: expected value, found trait `Default`
+ --> $DIR/slice-pat-type-mismatches.rs:33:11
+ |
+LL | match Default
+ | ^^^^^^^ not a value
+
error[E0529]: expected an array or slice, found `String`
--> $DIR/slice-pat-type-mismatches.rs:3:9
|
@@ -13,7 +19,7 @@ LL | ['f', 'o', ..] => {}
error[E0527]: pattern requires 1 element but array has 3
--> $DIR/slice-pat-type-mismatches.rs:18:9
|
-LL | [0] => {},
+LL | [0] => {}
| ^^^ expected 3 elements
error[E0528]: pattern requires at least 4 elements but array has 3
@@ -22,13 +28,7 @@ error[E0528]: pattern requires at least 4 elements but array has 3
LL | [0, 1, 2, 3, x @ ..] => {}
| ^^^^^^^^^^^^^^^^^^^^ pattern cannot match array of 3 elements
-error[E0282]: type annotations needed
- --> $DIR/slice-pat-type-mismatches.rs:34:9
- |
-LL | [] => {}
- | ^^ cannot infer type
-
error: aborting due to 5 previous errors
-Some errors have detailed explanations: E0282, E0425, E0527, E0528, E0529.
-For more information about an error, try `rustc --explain E0282`.
+Some errors have detailed explanations: E0423, E0425, E0527, E0528, E0529.
+For more information about an error, try `rustc --explain E0423`.
diff --git a/tests/ui/destructuring-assignment/slice_destructure_fail.rs b/tests/ui/destructuring-assignment/slice_destructure_fail.rs
index 33b09eb349d..e36557940ee 100644
--- a/tests/ui/destructuring-assignment/slice_destructure_fail.rs
+++ b/tests/ui/destructuring-assignment/slice_destructure_fail.rs
@@ -1,6 +1,10 @@
fn main() {
- let (mut a, mut b);
- [a, .., b, ..] = [0, 1]; //~ ERROR `..` can only be used once per slice pattern
- [a, a, b] = [1, 2]; //~ ERROR pattern requires 3 elements but array has 2
- [_] = [1, 2]; //~ ERROR pattern requires 1 element but array has 2
+ let (mut a, mut b);
+ [a, .., b, ..] = [0, 1]; //~ ERROR `..` can only be used once per slice pattern
+ [a, a, b] = [1, 2];
+ //~^ ERROR pattern requires 3 elements but array has 2
+ //~| ERROR mismatched types
+ [_] = [1, 2];
+ //~^ ERROR pattern requires 1 element but array has 2
+ //~| ERROR mismatched types
}
diff --git a/tests/ui/destructuring-assignment/slice_destructure_fail.stderr b/tests/ui/destructuring-assignment/slice_destructure_fail.stderr
index 92c86febac4..e42b9695d4d 100644
--- a/tests/ui/destructuring-assignment/slice_destructure_fail.stderr
+++ b/tests/ui/destructuring-assignment/slice_destructure_fail.stderr
@@ -1,23 +1,42 @@
error: `..` can only be used once per slice pattern
- --> $DIR/slice_destructure_fail.rs:3:14
+ --> $DIR/slice_destructure_fail.rs:3:16
|
-LL | [a, .., b, ..] = [0, 1];
- | -- ^^ can only be used once per slice pattern
- | |
- | previously used here
+LL | [a, .., b, ..] = [0, 1];
+ | -- ^^ can only be used once per slice pattern
+ | |
+ | previously used here
+
+error[E0308]: mismatched types
+ --> $DIR/slice_destructure_fail.rs:4:5
+ |
+LL | [a, a, b] = [1, 2];
+ | ^^^^^^^^^ expected an array with a fixed size of 2 elements, found one with 3 elements
+ |
+ = note: expected array `[{integer}; 2]`
+ found array `[_; 3]`
error[E0527]: pattern requires 3 elements but array has 2
- --> $DIR/slice_destructure_fail.rs:4:3
+ --> $DIR/slice_destructure_fail.rs:4:5
|
-LL | [a, a, b] = [1, 2];
- | ^^^^^^^^^ expected 2 elements
+LL | [a, a, b] = [1, 2];
+ | ^^^^^^^^^ expected 2 elements
+
+error[E0308]: mismatched types
+ --> $DIR/slice_destructure_fail.rs:7:5
+ |
+LL | [_] = [1, 2];
+ | ^^^ expected an array with a fixed size of 2 elements, found one with 1 element
+ |
+ = note: expected array `[{integer}; 2]`
+ found array `[_; 1]`
error[E0527]: pattern requires 1 element but array has 2
- --> $DIR/slice_destructure_fail.rs:5:3
+ --> $DIR/slice_destructure_fail.rs:7:5
|
-LL | [_] = [1, 2];
- | ^^^ expected 2 elements
+LL | [_] = [1, 2];
+ | ^^^ expected 2 elements
-error: aborting due to 3 previous errors
+error: aborting due to 5 previous errors
-For more information about this error, try `rustc --explain E0527`.
+Some errors have detailed explanations: E0308, E0527.
+For more information about an error, try `rustc --explain E0308`.
diff --git a/tests/ui/pattern/issue-76342.rs b/tests/ui/pattern/issue-76342.rs
new file mode 100644
index 00000000000..2b3d3e522f2
--- /dev/null
+++ b/tests/ui/pattern/issue-76342.rs
@@ -0,0 +1,16 @@
+// check-pass
+#![allow(unused_variables)]
+struct Zeroes;
+impl Into<[usize; 2]> for Zeroes {
+ fn into(self) -> [usize; 2] { [0; 2] }
+}
+impl Into<[usize; 3]> for Zeroes {
+ fn into(self) -> [usize; 3] { [0; 3] }
+}
+impl Into<[usize; 4]> for Zeroes {
+ fn into(self) -> [usize; 4] { [0; 4] }
+}
+fn main() {
+ let [a, b, c] = Zeroes.into(); // ERROR: type annotations needed
+ let [d, e, f]: [_; 3] = Zeroes.into(); // Works great
+}