Skip to content

Commit 40c5eef

Browse files
committed
add test for array len inference
1 parent 7f12561 commit 40c5eef

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// see issue #70529
2+
struct A;
3+
4+
impl From<A> for [u8; 2] {
5+
fn from(a: A) -> Self {
6+
[0; 2]
7+
}
8+
}
9+
10+
impl From<A> for [u8; 3] {
11+
fn from(a: A) -> Self {
12+
[0; 3]
13+
}
14+
}
15+
16+
17+
fn main() {
18+
let a = A;
19+
let [_, _] = a.into();
20+
//~^ ERROR type annotations needed
21+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0282]: type annotations needed
2+
--> $DIR/infer_array_len.rs:19:9
3+
|
4+
LL | let [_, _] = a.into();
5+
| ^^^^^^ consider giving this pattern a type
6+
|
7+
= note: type must be known at this point
8+
9+
error: aborting due to previous error
10+
11+
For more information about this error, try `rustc --explain E0282`.

0 commit comments

Comments
 (0)