Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CTFE: LongRunningWarn is getting implicitly deduplicated #118612

Closed
lcnr opened this issue Dec 4, 2023 · 3 comments · Fixed by #130665
Closed

CTFE: LongRunningWarn is getting implicitly deduplicated #118612

lcnr opened this issue Dec 4, 2023 · 3 comments · Fixed by #130665
Assignees
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Comments

@lcnr
Copy link
Contributor

lcnr commented Dec 4, 2023

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.

cc @oli-obk @RalfJung

@lcnr lcnr added the C-bug Category: This is a bug. label Dec 4, 2023
@rustbot rustbot added the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 4, 2023
@lcnr lcnr changed the title CTFE: LongRunningWarn is getting implcitly deduplicated CTFE: LongRunningWarn is getting implicitly deduplicated Dec 4, 2023
@lcnr lcnr added the A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) label Dec 4, 2023
@RalfJung
Copy link
Member

RalfJung commented Dec 4, 2023

It's whole point is to be repeated multiple times.

I honestly don't remember if we want it to be repeated or not.

Is there even a way for a single diagnostic to opt-out of deduplication? I guess we could put some number into the error message so that it's not the exact same diagnostic each time.

@lcnr
Copy link
Contributor Author

lcnr commented Dec 5, 2023

Is there even a way for a single diagnostic to opt-out of deduplication? I guess we could put some number into the error message so that it's not the exact same diagnostic each time.

yes, we have full ownership of rustc, we can the deduplication code to stop duplicating this single warning while keeping everything else the same 😁

@saethlin saethlin removed the needs-triage This issue may need triage. Remove it if it has been sufficiently triaged. label Dec 7, 2023
@veera-sivarajan
Copy link
Contributor

@rustbot claim

matthiaskrgr added a commit to matthiaskrgr/rust that referenced this issue Sep 21, 2024
…iler-errors

Prevent Deduplication of `LongRunningWarn`

Fixes rust-lang#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.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 22, 2024
…iler-errors

Prevent Deduplication of `LongRunningWarn`

Fixes rust-lang#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.
workingjubilee added a commit to workingjubilee/rustc that referenced this issue Sep 22, 2024
…iler-errors

Prevent Deduplication of `LongRunningWarn`

Fixes rust-lang#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.
@jieyouxu jieyouxu added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. labels Sep 22, 2024
@bors bors closed this as completed in b020864 Sep 22, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Sep 22, 2024
Rollup merge of rust-lang#130665 - veera-sivarajan:fix-118612, r=compiler-errors

Prevent Deduplication of `LongRunningWarn`

Fixes rust-lang#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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-const-eval Area: Constant evaluation, covers all const contexts (static, const fn, ...) C-bug Category: This is a bug. D-diagnostic-infra Diagnostics: Issues that affect all diagnostics, or relate to the diagnostic machinery itself. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants