diff options
Diffstat (limited to 'tests')
23 files changed, 177 insertions, 187 deletions
diff --git a/tests/ui/consts/const-eval/infinite_loop.rs b/tests/ui/consts/const-eval/infinite_loop.rs index 4babc9a2850..21781490637 100644 --- a/tests/ui/consts/const-eval/infinite_loop.rs +++ b/tests/ui/consts/const-eval/infinite_loop.rs @@ -4,8 +4,8 @@ fn main() { let _ = [(); { let mut n = 113383; // #20 in https://oeis.org/A006884 while n != 0 { - //~^ ERROR evaluation of constant value failed - n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; + //~^ ERROR is taking a long time + n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 }; } n }]; diff --git a/tests/ui/consts/const-eval/infinite_loop.stderr b/tests/ui/consts/const-eval/infinite_loop.stderr index f30bfaf3f95..f0434a847ce 100644 --- a/tests/ui/consts/const-eval/infinite_loop.stderr +++ b/tests/ui/consts/const-eval/infinite_loop.stderr @@ -1,12 +1,27 @@ -error[E0080]: evaluation of constant value failed +error: constant evaluation is taking a long time --> $DIR/infinite_loop.rs:6:9 | LL | / while n != 0 { LL | | -LL | | n = if n % 2 == 0 { n/2 } else { 3*n + 1 }; +LL | | n = if n % 2 == 0 { n / 2 } else { 3 * n + 1 }; LL | | } - | |_________^ exceeded interpreter step limit (see `#[const_eval_limit]`) + | |_________^ + | + = 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:4:18 + | +LL | let _ = [(); { + | __________________^ +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 previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/issue-52475.rs b/tests/ui/consts/const-eval/issue-52475.rs index 307c1a66834..ee26d280018 100644 --- a/tests/ui/consts/const-eval/issue-52475.rs +++ b/tests/ui/consts/const-eval/issue-52475.rs @@ -2,7 +2,8 @@ fn main() { let _ = [(); { let mut x = &0; let mut n = 0; - while n < 5 { //~ ERROR evaluation of constant value failed [E0080] + while n < 5 { + //~^ ERROR: constant evaluation is taking a long time n = (n + 1) % 5; x = &0; // Materialize a new AllocId } diff --git a/tests/ui/consts/const-eval/issue-52475.stderr b/tests/ui/consts/const-eval/issue-52475.stderr index 3aa6bd277dd..ebf9d12a66a 100644 --- a/tests/ui/consts/const-eval/issue-52475.stderr +++ b/tests/ui/consts/const-eval/issue-52475.stderr @@ -1,12 +1,28 @@ -error[E0080]: evaluation of constant value failed +error: constant evaluation is taking a long time --> $DIR/issue-52475.rs:5:9 | LL | / while n < 5 { +LL | | LL | | n = (n + 1) % 5; LL | | x = &0; // Materialize a new AllocId LL | | } - | |_________^ exceeded interpreter step limit (see `#[const_eval_limit]`) + | |_________^ + | + = 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/issue-52475.rs:2:18 + | +LL | let _ = [(); { + | __________________^ +LL | | let mut x = &0; +LL | | let mut n = 0; +LL | | while n < 5 { +... | +LL | | 0 +LL | | }]; + | |_____^ + = note: `#[deny(long_running_const_eval)]` on by default error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/issue-70723.rs b/tests/ui/consts/const-eval/issue-70723.rs index 3c81afa67a6..c8c809a25ed 100644 --- a/tests/ui/consts/const-eval/issue-70723.rs +++ b/tests/ui/consts/const-eval/issue-70723.rs @@ -1,3 +1,3 @@ -static _X: () = loop {}; //~ ERROR could not evaluate static initializer +static _X: () = loop {}; //~ ERROR taking a long time fn main() {} diff --git a/tests/ui/consts/const-eval/issue-70723.stderr b/tests/ui/consts/const-eval/issue-70723.stderr index 09fb3e060dc..572a430726f 100644 --- a/tests/ui/consts/const-eval/issue-70723.stderr +++ b/tests/ui/consts/const-eval/issue-70723.stderr @@ -1,9 +1,17 @@ -error[E0080]: could not evaluate static initializer +error: constant evaluation is taking a long time --> $DIR/issue-70723.rs:1:17 | LL | static _X: () = loop {}; - | ^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) + | ^^^^^^^ + | + = 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/issue-70723.rs:1:1 + | +LL | static _X: () = loop {}; + | ^^^^^^^^^^^^^ + = note: `#[deny(long_running_const_eval)]` on by default error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs index c59596238e1..a30518170ad 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs @@ -25,7 +25,7 @@ const fn call_foo() -> u32 { foo(); foo(); foo(); - foo(); //~ ERROR evaluation of constant value failed [E0080] + foo(); //~ ERROR is taking a long time 0 } diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr index ed70975af34..a3fd712ca46 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr @@ -1,20 +1,17 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ctfe-fn-call.rs:28:5 - | -LL | foo(); - | ^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) - | -note: inside `call_foo` +error: constant evaluation is taking a long time --> $DIR/ctfe-fn-call.rs:28:5 | LL | foo(); | ^^^^^ -note: inside `X` - --> $DIR/ctfe-fn-call.rs:32:16 + | + = 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/ctfe-fn-call.rs:32:1 | LL | const X: u32 = call_foo(); - | ^^^^^^^^^^ + | ^^^^^^^^^^^^ + = note: `#[deny(long_running_const_eval)]` on by default error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs index c10b8d83791..f7cd04568be 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs @@ -3,9 +3,10 @@ const fn labelled_loop(n: u32) -> u32 { let mut i = 0; - 'mylabel: loop { //~ ERROR evaluation of constant value failed [E0080] + 'mylabel: loop { + //~^ ERROR is taking a long time if i > n { - break 'mylabel + break 'mylabel; } i += 1; } diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr index d9404edd5b1..5808ee35a6b 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr @@ -1,30 +1,23 @@ -error[E0080]: evaluation of constant value failed +error: constant evaluation is taking a long time --> $DIR/ctfe-labelled-loop.rs:6:5 | LL | / 'mylabel: loop { +LL | | LL | | if i > n { -LL | | break 'mylabel -LL | | } -LL | | i += 1; -LL | | } - | |_____^ exceeded interpreter step limit (see `#[const_eval_limit]`) - | -note: inside `labelled_loop` - --> $DIR/ctfe-labelled-loop.rs:6:5 - | -LL | / 'mylabel: loop { -LL | | if i > n { -LL | | break 'mylabel +LL | | break 'mylabel; LL | | } LL | | i += 1; LL | | } | |_____^ -note: inside `X` - --> $DIR/ctfe-labelled-loop.rs:15:16 + | + = 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/ctfe-labelled-loop.rs:16:1 | LL | const X: u32 = labelled_loop(19); - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ + = note: `#[deny(long_running_const_eval)]` on by default error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs index 80ff835f3e8..56a39fc45b0 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs @@ -1,11 +1,12 @@ // check-fail // compile-flags: -Z tiny-const-eval-limit +#[rustfmt::skip] const fn recurse(n: u32) -> u32 { if n == 0 { n } else { - recurse(n - 1) //~ ERROR evaluation of constant value failed [E0080] + recurse(n - 1) //~ ERROR is taking a long time } } diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr index ed9a3111942..524c8e55426 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr @@ -1,25 +1,17 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ctfe-recursion.rs:8:9 - | -LL | recurse(n - 1) - | ^^^^^^^^^^^^^^ exceeded interpreter step limit (see `#[const_eval_limit]`) - | -note: inside `recurse` - --> $DIR/ctfe-recursion.rs:8:9 +error: constant evaluation is taking a long time + --> $DIR/ctfe-recursion.rs:9:9 | LL | recurse(n - 1) | ^^^^^^^^^^^^^^ -note: [... 18 additional calls inside `recurse` ...] - --> $DIR/ctfe-recursion.rs:8:9 | -LL | recurse(n - 1) - | ^^^^^^^^^^^^^^ -note: inside `X` - --> $DIR/ctfe-recursion.rs:12:16 + = 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/ctfe-recursion.rs:13:1 | LL | const X: u32 = recurse(19); - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^ + = note: `#[deny(long_running_const_eval)]` on by default error: aborting due to previous error -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr new file mode 100644 index 00000000000..30550f93ac1 --- /dev/null +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr @@ -0,0 +1,19 @@ +warning: constant evaluation is taking a long time + --> $DIR/ctfe-simple-loop.rs:9:5 + | +LL | / while index < n { +LL | | +LL | | +LL | | +LL | | index = index + 1; +LL | | } + | |_____^ the const evaluator is currently interpreting this expression + | +help: the constant being evaluated + --> $DIR/ctfe-simple-loop.rs:19:1 + | +LL | const Y: u32 = simple_loop(35); + | ^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs index ca0eec93c5d..214f33dfb36 100644 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs @@ -1,14 +1,22 @@ -// check-fail +// check-pass +// revisions: warn allow +#![cfg_attr(warn, warn(long_running_const_eval))] +#![cfg_attr(allow, allow(long_running_const_eval))] + // compile-flags: -Z tiny-const-eval-limit const fn simple_loop(n: u32) -> u32 { let mut index = 0; - while index < n { //~ ERROR evaluation of constant value failed [E0080] + while index < n { + //~^ WARN is taking a long time + //[warn]~| WARN is taking a long time + //[warn]~| WARN is taking a long time index = index + 1; } 0 } const X: u32 = simple_loop(19); +const Y: u32 = simple_loop(35); fn main() { println!("{X}"); diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr deleted file mode 100644 index 83ff275de70..00000000000 --- a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/ctfe-simple-loop.rs:5:5 - | -LL | / while index < n { -LL | | index = index + 1; -LL | | } - | |_____^ exceeded interpreter step limit (see `#[const_eval_limit]`) - | -note: inside `simple_loop` - --> $DIR/ctfe-simple-loop.rs:5:5 - | -LL | / while index < n { -LL | | index = index + 1; -LL | | } - | |_____^ -note: inside `X` - --> $DIR/ctfe-simple-loop.rs:11:16 - | -LL | const X: u32 = simple_loop(19); - | ^^^^^^^^^^^^^^^ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr new file mode 100644 index 00000000000..40fc4a876e9 --- /dev/null +++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr @@ -0,0 +1,62 @@ +warning: constant evaluation is taking a long time + --> $DIR/ctfe-simple-loop.rs:9:5 + | +LL | / while index < n { +LL | | +LL | | +LL | | +LL | | index = index + 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/ctfe-simple-loop.rs:18:1 + | +LL | const X: u32 = simple_loop(19); + | ^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/ctfe-simple-loop.rs:3:24 + | +LL | #![cfg_attr(warn, warn(long_running_const_eval))] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +warning: constant evaluation is taking a long time + --> $DIR/ctfe-simple-loop.rs:9:5 + | +LL | / while index < n { +LL | | +LL | | +LL | | +LL | | index = index + 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/ctfe-simple-loop.rs:19:1 + | +LL | const Y: u32 = simple_loop(35); + | ^^^^^^^^^^^^ + +warning: constant evaluation is taking a long time + --> $DIR/ctfe-simple-loop.rs:9:5 + | +LL | / while index < n { +LL | | +LL | | +LL | | +LL | | index = index + 1; +LL | | } + | |_____^ the const evaluator is currently interpreting this expression + | +help: the constant being evaluated + --> $DIR/ctfe-simple-loop.rs:19:1 + | +LL | const Y: u32 = simple_loop(35); + | ^^^^^^^^^^^^ + +warning: 3 warnings emitted + diff --git a/tests/ui/consts/const_limit/const_eval_limit_not_reached.rs b/tests/ui/consts/const_limit/const_eval_limit_not_reached.rs deleted file mode 100644 index 629d1f02a30..00000000000 --- a/tests/ui/consts/const_limit/const_eval_limit_not_reached.rs +++ /dev/null @@ -1,20 +0,0 @@ -// check-pass - -#![feature(const_eval_limit)] - -// This needs to be higher than the number of loop iterations since each pass through the loop may -// hit more than one terminator. -#![const_eval_limit="4000"] - -const X: usize = { - let mut x = 0; - while x != 1000 { - x += 1; - } - - x -}; - -fn main() { - assert_eq!(X, 1000); -} diff --git a/tests/ui/consts/const_limit/const_eval_limit_overflow.rs b/tests/ui/consts/const_limit/const_eval_limit_overflow.rs deleted file mode 100644 index 1c49593cd53..00000000000 --- a/tests/ui/consts/const_limit/const_eval_limit_overflow.rs +++ /dev/null @@ -1,15 +0,0 @@ -#![feature(const_eval_limit)] -#![const_eval_limit="18_446_744_073_709_551_615"] -//~^ ERROR `limit` must be a non-negative integer - -const CONSTANT: usize = limit(); - -fn main() { - assert_eq!(CONSTANT, 1764); -} - -const fn limit() -> usize { - let x = 42; - - x * 42 -} diff --git a/tests/ui/consts/const_limit/const_eval_limit_overflow.stderr b/tests/ui/consts/const_limit/const_eval_limit_overflow.stderr deleted file mode 100644 index 7f5d5e6cd4c..00000000000 --- a/tests/ui/consts/const_limit/const_eval_limit_overflow.stderr +++ /dev/null @@ -1,10 +0,0 @@ -error: `limit` must be a non-negative integer - --> $DIR/const_eval_limit_overflow.rs:2:1 - | -LL | #![const_eval_limit="18_446_744_073_709_551_615"] - | ^^^^^^^^^^^^^^^^^^^^----------------------------^ - | | - | not a valid integer - -error: aborting due to previous error - diff --git a/tests/ui/consts/const_limit/const_eval_limit_reached.rs b/tests/ui/consts/const_limit/const_eval_limit_reached.rs deleted file mode 100644 index 3ce038c1d3f..00000000000 --- a/tests/ui/consts/const_limit/const_eval_limit_reached.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(const_eval_limit)] -#![const_eval_limit = "500"] - -const X: usize = { - let mut x = 0; - while x != 1000 { - //~^ ERROR evaluation of constant value failed - x += 1; - } - - x -}; - -fn main() { - assert_eq!(X, 1000); -} diff --git a/tests/ui/consts/const_limit/const_eval_limit_reached.stderr b/tests/ui/consts/const_limit/const_eval_limit_reached.stderr deleted file mode 100644 index a8e8ae9bb08..00000000000 --- a/tests/ui/consts/const_limit/const_eval_limit_reached.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0080]: evaluation of constant value failed - --> $DIR/const_eval_limit_reached.rs:6:5 - | -LL | / while x != 1000 { -LL | | -LL | | x += 1; -LL | | } - | |_____^ exceeded interpreter step limit (see `#[const_eval_limit]`) - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.rs b/tests/ui/consts/const_limit/feature-gate-const_eval_limit.rs deleted file mode 100644 index 61119d7511d..00000000000 --- a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![const_eval_limit="42"] -//~^ ERROR the `#[const_eval_limit]` attribute is an experimental feature [E0658] - -const CONSTANT: usize = limit(); - -fn main() { - assert_eq!(CONSTANT, 1764); -} - -const fn limit() -> usize { - let x = 42; - - x * 42 -} diff --git a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.stderr b/tests/ui/consts/const_limit/feature-gate-const_eval_limit.stderr deleted file mode 100644 index 5bd29c7dfd2..00000000000 --- a/tests/ui/consts/const_limit/feature-gate-const_eval_limit.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: the `#[const_eval_limit]` attribute is an experimental feature - --> $DIR/feature-gate-const_eval_limit.rs:1:1 - | -LL | #![const_eval_limit="42"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #67217 <https://github.com/rust-lang/rust/issues/67217> for more information - = help: add `#![feature(const_eval_limit)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. |
