From c81521ae545faf9e2b6c212f9e3faea69fde4d01 Mon Sep 17 00:00:00 2001 From: yukang Date: Fri, 8 Mar 2024 15:09:53 +0800 Subject: Fix crash in late internal checking --- .../const-eval/infinite_loop.eval_limit.stderr | 27 ++++++++++++++++++++++ .../consts/const-eval/infinite_loop.no_ice.stderr | 27 ++++++++++++++++++++++ tests/ui/consts/const-eval/infinite_loop.rs | 5 +++- tests/ui/consts/const-eval/infinite_loop.stderr | 27 ---------------------- 4 files changed, 58 insertions(+), 28 deletions(-) create mode 100644 tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr create mode 100644 tests/ui/consts/const-eval/infinite_loop.no_ice.stderr delete mode 100644 tests/ui/consts/const-eval/infinite_loop.stderr (limited to 'tests/ui') diff --git a/tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr b/tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr new file mode 100644 index 00000000000..d664ae88323 --- /dev/null +++ b/tests/ui/consts/const-eval/infinite_loop.eval_limit.stderr @@ -0,0 +1,27 @@ +error: constant evaluation is taking a long time + --> $DIR/infinite_loop.rs:15:9 + | +LL | / while n != 0 { +LL | | +LL | | n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 }; +LL | | } + | |_________^ + | + = 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/infinite_loop.rs:13:18 + | +LL | let s = [(); { + | __________________^ +LL | | let mut n = 113383; // #20 in https://oeis.org/A006884 +LL | | while n != 0 { +LL | | +... | +LL | | n +LL | | }]; + | |_____^ + = note: `#[deny(long_running_const_eval)]` on by default + +error: aborting due to 1 previous error + diff --git a/tests/ui/consts/const-eval/infinite_loop.no_ice.stderr b/tests/ui/consts/const-eval/infinite_loop.no_ice.stderr new file mode 100644 index 00000000000..d664ae88323 --- /dev/null +++ b/tests/ui/consts/const-eval/infinite_loop.no_ice.stderr @@ -0,0 +1,27 @@ +error: constant evaluation is taking a long time + --> $DIR/infinite_loop.rs:15:9 + | +LL | / while n != 0 { +LL | | +LL | | n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 }; +LL | | } + | |_________^ + | + = 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/infinite_loop.rs:13:18 + | +LL | let s = [(); { + | __________________^ +LL | | let mut n = 113383; // #20 in https://oeis.org/A006884 +LL | | while n != 0 { +LL | | +... | +LL | | n +LL | | }]; + | |_____^ + = note: `#[deny(long_running_const_eval)]` on by default + +error: aborting due to 1 previous error + diff --git a/tests/ui/consts/const-eval/infinite_loop.rs b/tests/ui/consts/const-eval/infinite_loop.rs index 44456f1ce47..f8cb79b63db 100644 --- a/tests/ui/consts/const-eval/infinite_loop.rs +++ b/tests/ui/consts/const-eval/infinite_loop.rs @@ -1,8 +1,11 @@ //! This test tests two things at once: //! 1. we error if a const evaluation hits the deny-by-default lint limit //! 2. we do not ICE on invalid follow-up code +//! 3. no ICE when run with `-Z unstable-options` (issue 122177) -//@ compile-flags: -Z tiny-const-eval-limit +//@revisions: eval_limit no_ice +//@[no_ice] compile-flags: -Z tiny-const-eval-limit -Z unstable-options +//@[eval_limit] compile-flags: -Z tiny-const-eval-limit fn main() { // Tests the Collatz conjecture with an incorrect base case (0 instead of 1). diff --git a/tests/ui/consts/const-eval/infinite_loop.stderr b/tests/ui/consts/const-eval/infinite_loop.stderr deleted file mode 100644 index 37cd94bf7b7..00000000000 --- a/tests/ui/consts/const-eval/infinite_loop.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error: constant evaluation is taking a long time - --> $DIR/infinite_loop.rs:12:9 - | -LL | / while n != 0 { -LL | | -LL | | n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 }; -LL | | } - | |_________^ - | - = 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/infinite_loop.rs:10:18 - | -LL | let s = [(); { - | __________________^ -LL | | let mut n = 113383; // #20 in https://oeis.org/A006884 -LL | | while n != 0 { -LL | | -... | -LL | | n -LL | | }]; - | |_____^ - = note: `#[deny(long_running_const_eval)]` on by default - -error: aborting due to 1 previous error - -- cgit 1.4.1-3-g733a5