-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
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".
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.