Skip to content

Commit

Permalink
Rollup merge of #112925 - oli-obk:timeout_lint, r=cjgillot
Browse files Browse the repository at this point in the history
Stop hiding const eval limit in external macros

fixes #112748

We don't emit a hard error if there was a previous deny lint triggering with the same message. If that lint ends up not being emitted, we ICE and don't emit an error either.
  • Loading branch information
matthiaskrgr authored Jun 23, 2023
2 parents 4e89830 + aacd702 commit c913952
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/rustc_lint_defs/src/builtin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3464,7 +3464,8 @@ declare_lint! {
/// out an update in your own time.
pub LONG_RUNNING_CONST_EVAL,
Deny,
"detects long const eval operations"
"detects long const eval operations",
report_in_external_macro
}

declare_lint! {
Expand Down
25 changes: 25 additions & 0 deletions tests/ui/consts/timeout.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
//! This test checks that external macros don't hide
//! the const eval timeout lint and then subsequently
//! ICE.
// compile-flags: --crate-type=lib -Ztiny-const-eval-limit
// error-pattern: constant evaluation is taking a long time

static ROOK_ATTACKS_TABLE: () = {
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
0_u64.count_ones();
};
15 changes: 15 additions & 0 deletions tests/ui/consts/timeout.stderr
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
error: constant evaluation is taking a long time
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
|
= note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
If your compilation actually takes a long time, you can safely allow the lint.
help: the constant being evaluated
--> $DIR/timeout.rs:8:1
|
LL | static ROOK_ATTACKS_TABLE: () = {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: `#[deny(long_running_const_eval)]` on by default
= note: this error originates in the macro `uint_impl` (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

0 comments on commit c913952

Please sign in to comment.