mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
87d8f5885b
- On `const` and `static` point at the type (like we do for let bindings) - On fn calls, point at const parameter in fn definition - On type, point at const parameter in type definition - On array type lengths, explain that array length is always `usize` - On enum variant discriminant, mention `repr`
17 lines
451 B
Rust
17 lines
451 B
Rust
const ARR: [i32; 6] = [42, 43, 44, 45, 46, 47];
|
|
const IDX: usize = 3;
|
|
const VAL: i32 = ARR[IDX];
|
|
const BONG: [i32; (ARR[0] - 41) as usize] = [5];
|
|
const BLUB: [i32; (ARR[0] - 40) as usize] = [5];
|
|
//~^ ERROR: mismatched types
|
|
//~| NOTE: expected an array
|
|
//~| NOTE: expected because
|
|
const BOO: [i32; (ARR[0] - 41) as usize] = [5, 99];
|
|
//~^ ERROR: mismatched types
|
|
//~| NOTE: expected an array
|
|
//~| NOTE: expected because
|
|
|
|
fn main() {
|
|
let _ = VAL;
|
|
}
|