Closed
Description
I tried the following code:
#![allow(long_running_const_eval)]
const FOO: () = loop {};
fn main() {
FOO
}
output after running for a very long time:
warning: constant evaluation is taking a long time
--> src/main.rs:2:17
|
2 | const FOO: () = loop {};
| ^^^^^^^ the const evaluator is currently interpreting this expression
|
help: the constant being evaluated
--> src/main.rs:2:1
|
2 | const FOO: () = loop {};
| ^^^^^^^^^^^^^
modify rustc as follows results in the following output:
diff --git a/compiler/rustc_const_eval/src/const_eval/machine.rs b/compiler/rustc_const_eval/src/const_eval/machine.rs
index 2d8ca67c3a5..1bf7949725b 100644
--- a/compiler/rustc_const_eval/src/const_eval/machine.rs
+++ b/compiler/rustc_const_eval/src/const_eval/machine.rs
@@ -593,6 +593,9 @@ fn increment_const_eval_counter(ecx: &mut InterpCx<'mir, 'tcx, Self>) -> InterpR
};
ecx.machine.num_evaluated_steps = new_steps;
+ if new_steps.is_power_of_two() {
+ eprintln!("power of two : {new_steps}");
+ }
// By default, we have a *deny* lint kicking in after some time
// to ensure `loop {}` doesn't just go forever.
// In case that lint got reduced, in particular for `--cap-lint` situations, we also
Compiling test1 v0.1.0 (/home/lcnr/test1)
power of two : 1
power of two : 2
power of two : 4
power of two : 8
power of two : 16
power of two : 32
power of two : 64
power of two : 128
power of two : 256
power of two : 512
power of two : 1024
power of two : 2048
power of two : 4096
power of two : 8192
power of two : 16384
power of two : 32768
power of two : 65536
power of two : 131072
power of two : 262144
power of two : 524288
power of two : 1048576
power of two : 2097152
power of two : 4194304
warning: constant evaluation is taking a long time
--> src/main.rs:2:17
|
2 | const FOO: () = loop {};
| ^^^^^^^ the const evaluator is currently interpreting this expression
|
help: the constant being evaluated
--> src/main.rs:2:1
|
2 | const FOO: () = loop {};
| ^^^^^^^^^^^^^
power of two : 8388608
power of two : 16777216
power of two : 33554432
power of two : 67108864
power of two : 134217728
changing the invocation to cargo rustc -- -Zdeduplicate-diagnostics=no
actually prints the warning at each power of two of steps.
This warning should not be affected by deduplicate-diagnostics
. It's whole point is to be repeated multiple times.