Closed
Description
Given the following code:
#![allow(incomplete_features)]
#![feature(const_generics, const_evaluatable_checked)]
use arrayvec::ArrayVec; // 0.5.2
fn append<T, const N: usize>(start: [T; N], v: T) -> [T; N + 1] {
let xs = ArrayVec::new();
for _ in 0..N {
xs.push(v);
}
xs.push(v);
match xs.into_inner() {
Ok(xs) => xs,
_ => unreachable!()
}
}
The current output is:
error[E0283]: type annotations needed for `ArrayVec<[T; _]>`
--> src/lib.rs:7:14
|
7 | let xs = ArrayVec::new();
| -- ^^^^^^^^^^^^^ cannot infer type for array `[T; _]`
| |
| consider giving `xs` the explicit type `ArrayVec<[T; _]>`, where the type parameter `[T; _]` is specified
|
= note: cannot satisfy `[T; _]: Array`
= note: required by `ArrayVec::<A>::new`
Ideally the output should:
- Not tell me to add a type when that's not the real problem.
- Not tell me to add a type after I add one and it doesn't solve the problem.
- Focus on the fact that the trait bound isn't satisfied for arbitrary
N
.
- 1.52.0-nightly (2021-03-07 234781a)