-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-inferenceArea: Type inferenceArea: Type inferenceC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.
Description
It would be nice if _
were allowed instead of an expression for the length in array types and array expressions, in cases where the length can be inferred based on context:
fn main() {
let a: [u8; 4] = [0; _];
let b: [u8; _] = a;
}
rustc 1.17.0-nightly (b1e3176 2017-03-03)
error: expected expression, found `_`
--> a.rs:2:26
|
2 | let a: [u8; 4] = [0; _];
| ^
error: expected expression, found `_`
--> a.rs:3:17
|
3 | let b: [u8; _] = a;
| ^
error: aborting due to 2 previous error
In comparison, the item type in array expressions and array types can be inferred today:
fn main() {
let a: [u8; 4] = ["0".parse::<_>().unwrap(); 4];
let b: [_; 4] = a;
}
est31, hanna-kruppe, eddyb, mcarton, burdges and 27 more
Metadata
Metadata
Assignees
Labels
A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)Area: Constant evaluation, covers all const contexts (static, const fn, ...)A-inferenceArea: Type inferenceArea: Type inferenceC-feature-requestCategory: A feature request, i.e: not implemented / a PR.Category: A feature request, i.e: not implemented / a PR.