rust-lang/rust

[tracking issue] warnings on long running constant evaluations

oli-obk opened this issue · 5 comments

#49947 introduces a warning (removing the previous hard error).

This warning is currently unsilenceable and should probably become a lint. For simplicity (#49947 needs to be backported to beta) this has not been done.

"When" the warning appears is deterministic, but depends on MIR, so it might change between versions of rustc.

rcoh commented

Seems like this will also require a small amount of refactoring? I don't think the evaluator where the warning is currently emitted knows the NodeId that is needed when emitting the lint.

We should be reporting the lint on the constant that is being evaluated, not the place that we are currently at, because that place might change between rustc versions

Note that just turning this into a lint is probably not enough. We need to also check whether the lint is deny in the constant's scope. If it is, we need to abort the interpretation. Otherwise we'd just keep getting these lints as errors without ever stopping compilation.

Triage: I'm not aware of any changes here. I'm also not sure what to do to reproduce this issue, to be honest.

static FOO: () = loop {}; gives (on beta)

error[E0080]: could not evaluate static initializer
 --> src/lib.rs:1:18
  |
1 | static FOO: () = loop {};
  |                  ^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`)

So I think we're good here