Skip to content

Commit

Permalink
Stop hiding const eval limit in external macros
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed Jun 22, 2023
1 parent c55d1ee commit aacd702
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 aacd702

Please sign in to comment.