Rollup merge of #130665 - veera-sivarajan:fix-118612, r=compiler-errors
Prevent Deduplication of `LongRunningWarn` Fixes #118612 As mention in the issue, `LongRunningWarn` is meant to be repeated multiple times. Therefore, this PR stores a unique number in every instance of `LongRunningWarn` so that it's not hashed into the same value and omitted by the deduplication mechanism.
This commit is contained in:
commit
b0208640c6
@ -641,7 +641,14 @@ fn increment_const_eval_counter(ecx: &mut InterpCx<'tcx, Self>) -> InterpResult<
|
||||
// current number of evaluated terminators is a power of 2. The latter gives us a cheap
|
||||
// way to implement exponential backoff.
|
||||
let span = ecx.cur_span();
|
||||
ecx.tcx.dcx().emit_warn(LongRunningWarn { span, item_span: ecx.tcx.span });
|
||||
// We store a unique number in `force_duplicate` to evade `-Z deduplicate-diagnostics`.
|
||||
// `new_steps` is guaranteed to be unique because `ecx.machine.num_evaluated_steps` is
|
||||
// always increasing.
|
||||
ecx.tcx.dcx().emit_warn(LongRunningWarn {
|
||||
span,
|
||||
item_span: ecx.tcx.span,
|
||||
force_duplicate: new_steps,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -209,6 +209,8 @@ pub struct LongRunningWarn {
|
||||
pub span: Span,
|
||||
#[help]
|
||||
pub item_span: Span,
|
||||
// Used for evading `-Z deduplicate-diagnostics`.
|
||||
pub force_duplicate: usize,
|
||||
}
|
||||
|
||||
#[derive(Subdiagnostic)]
|
||||
|
@ -0,0 +1,24 @@
|
||||
//@ check-pass
|
||||
|
||||
#![allow(long_running_const_eval)]
|
||||
|
||||
//@ compile-flags: -Z tiny-const-eval-limit -Z deduplicate-diagnostics=yes
|
||||
const FOO: () = {
|
||||
let mut i = 0;
|
||||
loop {
|
||||
//~^ WARN is taking a long time
|
||||
//~| WARN is taking a long time
|
||||
//~| WARN is taking a long time
|
||||
//~| WARN is taking a long time
|
||||
//~| WARN is taking a long time
|
||||
if i == 1000 {
|
||||
break;
|
||||
} else {
|
||||
i += 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
fn main() {
|
||||
FOO
|
||||
}
|
@ -0,0 +1,92 @@
|
||||
warning: constant evaluation is taking a long time
|
||||
--> $DIR/evade-deduplication-issue-118612.rs:8:5
|
||||
|
|
||||
LL | / loop {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^ the const evaluator is currently interpreting this expression
|
||||
|
|
||||
help: the constant being evaluated
|
||||
--> $DIR/evade-deduplication-issue-118612.rs:6:1
|
||||
|
|
||||
LL | const FOO: () = {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
warning: constant evaluation is taking a long time
|
||||
--> $DIR/evade-deduplication-issue-118612.rs:8:5
|
||||
|
|
||||
LL | / loop {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^ the const evaluator is currently interpreting this expression
|
||||
|
|
||||
help: the constant being evaluated
|
||||
--> $DIR/evade-deduplication-issue-118612.rs:6:1
|
||||
|
|
||||
LL | const FOO: () = {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
warning: constant evaluation is taking a long time
|
||||
--> $DIR/evade-deduplication-issue-118612.rs:8:5
|
||||
|
|
||||
LL | / loop {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^ the const evaluator is currently interpreting this expression
|
||||
|
|
||||
help: the constant being evaluated
|
||||
--> $DIR/evade-deduplication-issue-118612.rs:6:1
|
||||
|
|
||||
LL | const FOO: () = {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
warning: constant evaluation is taking a long time
|
||||
--> $DIR/evade-deduplication-issue-118612.rs:8:5
|
||||
|
|
||||
LL | / loop {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^ the const evaluator is currently interpreting this expression
|
||||
|
|
||||
help: the constant being evaluated
|
||||
--> $DIR/evade-deduplication-issue-118612.rs:6:1
|
||||
|
|
||||
LL | const FOO: () = {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
warning: constant evaluation is taking a long time
|
||||
--> $DIR/evade-deduplication-issue-118612.rs:8:5
|
||||
|
|
||||
LL | / loop {
|
||||
LL | |
|
||||
LL | |
|
||||
LL | |
|
||||
... |
|
||||
LL | | }
|
||||
LL | | }
|
||||
| |_____^ the const evaluator is currently interpreting this expression
|
||||
|
|
||||
help: the constant being evaluated
|
||||
--> $DIR/evade-deduplication-issue-118612.rs:6:1
|
||||
|
|
||||
LL | const FOO: () = {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
warning: 5 warnings emitted
|
||||
|
Loading…
Reference in New Issue
Block a user