Closed
Description
This code:
#![feature(min_const_generics)]
fn foo<const N: usize, const K: usize>(data: [u32; N]) -> [u32; K] {
[0; K]
}
fn main() {
let a = foo::<_, 2>([0, 1, 2]);
}
Gives (with rustc 1.50.0-nightly 349b3b3 2020-11-29):
error[E0747]: type provided when a constant was expected
--> ...\test.rs:6:19
|
6 | let a = foo::<_, 2>([0, 1, 2]);
| ^
Two problems:
- In the code I've used the underscore hoping rustc to infer the value of N, but for some reason it failed.
- Beside the type inference failure, the error message is not the best possible. I didn't provide a type. A better error message could say "unable to infer the const argument N, please specify".