summaryrefslogtreecommitdiffstats
path: root/tests/ui/consts/const-eval/stable-metric
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui/consts/const-eval/stable-metric')
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs2
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr19
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs5
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr27
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs3
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr24
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.allow.stderr19
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs12
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr24
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.warn.stderr62
10 files changed, 123 insertions, 74 deletions
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 c59596238..a30518170 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 ed70975af..a3fd712ca 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 c10b8d837..f7cd04568 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 d9404edd5..5808ee35a 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 80ff835f3..56a39fc45 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 ed9a31119..524c8e554 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 000000000..30550f93a
--- /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 ca0eec93c..214f33dfb 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 83ff275de..000000000
--- 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 000000000..40fc4a876
--- /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
+