add test for array len inference
This commit is contained in:
parent
7f12561135
commit
40c5eefdcd
2 changed files with 32 additions and 0 deletions
21
src/test/ui/array-slice-vec/infer_array_len.rs
Normal file
21
src/test/ui/array-slice-vec/infer_array_len.rs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// see issue #70529
|
||||
struct A;
|
||||
|
||||
impl From<A> for [u8; 2] {
|
||||
fn from(a: A) -> Self {
|
||||
[0; 2]
|
||||
}
|
||||
}
|
||||
|
||||
impl From<A> for [u8; 3] {
|
||||
fn from(a: A) -> Self {
|
||||
[0; 3]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fn main() {
|
||||
let a = A;
|
||||
let [_, _] = a.into();
|
||||
//~^ ERROR type annotations needed
|
||||
}
|
||||
11
src/test/ui/array-slice-vec/infer_array_len.stderr
Normal file
11
src/test/ui/array-slice-vec/infer_array_len.stderr
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
error[E0282]: type annotations needed
|
||||
--> $DIR/infer_array_len.rs:19:9
|
||||
|
|
||||
LL | let [_, _] = a.into();
|
||||
| ^^^^^^ consider giving this pattern a type
|
||||
|
|
||||
= note: type must be known at this point
|
||||
|
||||
error: aborting due to previous error
|
||||
|
||||
For more information about this error, try `rustc --explain E0282`.
|
||||
Loading…
Add table
Add a link
Reference in a new issue