Skip to content

const eval interpreter step limit being hit on nightly for long-running while loop #103814

Closed
@pnkfelix

Description

@pnkfelix

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)

Metadata

Metadata

Assignees

Labels

A-const-evalArea: Constant evaluation, covers all const contexts (static, const fn, ...)C-bugCategory: This is a bug.P-highHigh priorityT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.regression-from-stable-to-betaPerformance or correctness regression from stable to beta.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions