-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsF-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.const-generics-bad-diagnosticsAn error is correctly emitted, but is confusing, for `min_const_generics`.An error is correctly emitted, but is confusing, for `min_const_generics`.
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)
Metadata
Metadata
Assignees
Labels
A-const-genericsArea: const generics (parameters and arguments)Area: const generics (parameters and arguments)A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsF-generic_const_exprs`#![feature(generic_const_exprs)]``#![feature(generic_const_exprs)]`T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.const-generics-bad-diagnosticsAn error is correctly emitted, but is confusing, for `min_const_generics`.An error is correctly emitted, but is confusing, for `min_const_generics`.