Closed
Description
I tried this code (playpen):
const _DUMMY: u8 = {
let mut data = [0; 131072];
let mut idx = 0;
while idx < data.len() {
data[idx] = idx as u8;
idx += 1;
}
5
};
#[test]
fn check() { }
I expected to see this happen: Code compiles, test runs and passes.
Instead, this happened: Code fails to compile, due to:
error[[E0080]](https://doc.rust-lang.org/nightly/error-index.html#E0080): evaluation of constant value failed
--> src/lib.rs:6:9
|
6 | idx += 1;
| ^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)
For more information about this error, try `rustc --explain E0080`.
It does not occur on stable or beta.
(To be clear: I suspect this might be a const-eval implementation artifact that we cannot readily address. But we may need to figure out how to give better guidance, since the current diagnostic is telling people to muck with an attribute that is not available without opting into a feature gate.)
Meta
rustc --version --verbose
:
Nightly channel
Build using the Nightly version: 1.67.0-nightly
(2022-10-30 77e57db384aca99444c3)