Closed
Description
Case 1
fn main() {
const N: u8 = !0;
let _foo: [u8; 255] = [0; N as usize];
}
<anon>:3:27: 3:42 error: mismatched types:
expected `[u8; 255]`,
found `[u8; 18446744073709551615]`
(expected an array with a fixed size of 255 elements,
found one with 18446744073709551615 elements) [E0308]
<anon>:3 let _foo: [u8; 255] = [0; N as usize];
^~~~~~~~~~~~~~~
error: aborting due to previous error
Case 2
fn main() {
const N: u8 = 0 as u8 - 1 as u8;
let _foo: [u8; 255] = [0; N as usize];
}
<anon>:3:31: 3:41 error: expected constant integer for repeat count, found non-constant expression [E0307]
<anon>:3 let _foo: [u8; 255] = [0; N as usize];
^~~~~~~~~~
<anon>:3:27: 3:42 error: mismatched types:
expected `[u8; 255]`,
found `[u8; 0]`
(expected an array with a fixed size of 255 elements,
found one with 0 elements) [E0308]
<anon>:3 let _foo: [u8; 255] = [0; N as usize];
^~~~~~~~~~~~~~~
error: aborting due to 2 previous errors```
cc #13763
----
Update: revised test cases to run in playpen on modern rust, and updated error messages accordingly.
Metadata
Metadata
Assignees
Labels
No labels