Skip to content

Commit c913952

Browse files
authored
Rollup merge of #112925 - oli-obk:timeout_lint, r=cjgillot
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.
2 parents 4e89830 + aacd702 commit c913952

File tree

3 files changed

+42
-1
lines changed

3 files changed

+42
-1
lines changed

compiler/rustc_lint_defs/src/builtin.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -3464,7 +3464,8 @@ declare_lint! {
34643464
/// out an update in your own time.
34653465
pub LONG_RUNNING_CONST_EVAL,
34663466
Deny,
3467-
"detects long const eval operations"
3467+
"detects long const eval operations",
3468+
report_in_external_macro
34683469
}
34693470

34703471
declare_lint! {

tests/ui/consts/timeout.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
//! This test checks that external macros don't hide
2+
//! the const eval timeout lint and then subsequently
3+
//! ICE.
4+
5+
// compile-flags: --crate-type=lib -Ztiny-const-eval-limit
6+
// error-pattern: constant evaluation is taking a long time
7+
8+
static ROOK_ATTACKS_TABLE: () = {
9+
0_u64.count_ones();
10+
0_u64.count_ones();
11+
0_u64.count_ones();
12+
0_u64.count_ones();
13+
0_u64.count_ones();
14+
0_u64.count_ones();
15+
0_u64.count_ones();
16+
0_u64.count_ones();
17+
0_u64.count_ones();
18+
0_u64.count_ones();
19+
0_u64.count_ones();
20+
0_u64.count_ones();
21+
0_u64.count_ones();
22+
0_u64.count_ones();
23+
0_u64.count_ones();
24+
0_u64.count_ones();
25+
};

tests/ui/consts/timeout.stderr

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
error: constant evaluation is taking a long time
2+
--> $SRC_DIR/core/src/num/mod.rs:LL:COL
3+
|
4+
= note: this lint makes sure the compiler doesn't get stuck due to infinite loops in const eval.
5+
If your compilation actually takes a long time, you can safely allow the lint.
6+
help: the constant being evaluated
7+
--> $DIR/timeout.rs:8:1
8+
|
9+
LL | static ROOK_ATTACKS_TABLE: () = {
10+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
11+
= note: `#[deny(long_running_const_eval)]` on by default
12+
= note: this error originates in the macro `uint_impl` (in Nightly builds, run with -Z macro-backtrace for more info)
13+
14+
error: aborting due to previous error
15+

0 commit comments

Comments
 (0)