Stop hiding const eval limit in external macros

This commit is contained in:
Oli Scherer 2023-06-22 14:11:10 +00:00
parent c55d1ee8d4
commit aacd702895
3 changed files with 42 additions and 1 deletions

View File

@ -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! {

View File

@ -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();
};

View File

@ -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