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.rs36
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr20
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs19
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr30
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs16
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr25
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs15
-rw-r--r--tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr24
-rw-r--r--tests/ui/consts/const-eval/stable-metric/dominators-edge-case.rs19
9 files changed, 204 insertions, 0 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
new file mode 100644
index 000000000..c59596238
--- /dev/null
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs
@@ -0,0 +1,36 @@
+// check-fail
+// compile-flags: -Z tiny-const-eval-limit
+
+const fn foo() {}
+
+const fn call_foo() -> u32 {
+ foo();
+ foo();
+ foo();
+ foo();
+ foo();
+
+ foo();
+ foo();
+ foo();
+ foo();
+ foo();
+
+ foo();
+ foo();
+ foo();
+ foo();
+ foo();
+
+ foo();
+ foo();
+ foo();
+ foo(); //~ ERROR evaluation of constant value failed [E0080]
+ 0
+}
+
+const X: u32 = call_foo();
+
+fn main() {
+ println!("{X}");
+}
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
new file mode 100644
index 000000000..ed70975af
--- /dev/null
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr
@@ -0,0 +1,20 @@
+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`
+ --> $DIR/ctfe-fn-call.rs:28:5
+ |
+LL | foo();
+ | ^^^^^
+note: inside `X`
+ --> $DIR/ctfe-fn-call.rs:32:16
+ |
+LL | const X: u32 = call_foo();
+ | ^^^^^^^^^^
+
+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
new file mode 100644
index 000000000..c10b8d837
--- /dev/null
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs
@@ -0,0 +1,19 @@
+// check-fail
+// compile-flags: -Z tiny-const-eval-limit
+
+const fn labelled_loop(n: u32) -> u32 {
+ let mut i = 0;
+ 'mylabel: loop { //~ ERROR evaluation of constant value failed [E0080]
+ if i > n {
+ break 'mylabel
+ }
+ i += 1;
+ }
+ 0
+}
+
+const X: u32 = labelled_loop(19);
+
+fn main() {
+ println!("{X}");
+}
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
new file mode 100644
index 000000000..d9404edd5
--- /dev/null
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr
@@ -0,0 +1,30 @@
+error[E0080]: evaluation of constant value failed
+ --> $DIR/ctfe-labelled-loop.rs:6:5
+ |
+LL | / 'mylabel: loop {
+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 | | }
+LL | | i += 1;
+LL | | }
+ | |_____^
+note: inside `X`
+ --> $DIR/ctfe-labelled-loop.rs:15:16
+ |
+LL | const X: u32 = labelled_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-recursion.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs
new file mode 100644
index 000000000..80ff835f3
--- /dev/null
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs
@@ -0,0 +1,16 @@
+// check-fail
+// compile-flags: -Z tiny-const-eval-limit
+
+const fn recurse(n: u32) -> u32 {
+ if n == 0 {
+ n
+ } else {
+ recurse(n - 1) //~ ERROR evaluation of constant value failed [E0080]
+ }
+}
+
+const X: u32 = recurse(19);
+
+fn main() {
+ println!("{X}");
+}
diff --git a/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr
new file mode 100644
index 000000000..ed9a31119
--- /dev/null
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr
@@ -0,0 +1,25 @@
+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
+ |
+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
+ |
+LL | const X: u32 = recurse(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.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs
new file mode 100644
index 000000000..ca0eec93c
--- /dev/null
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs
@@ -0,0 +1,15 @@
+// check-fail
+// 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]
+ index = index + 1;
+ }
+ 0
+}
+
+const X: u32 = simple_loop(19);
+
+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
new file mode 100644
index 000000000..83ff275de
--- /dev/null
+++ b/tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr
@@ -0,0 +1,24 @@
+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/dominators-edge-case.rs b/tests/ui/consts/const-eval/stable-metric/dominators-edge-case.rs
new file mode 100644
index 000000000..0b0f36180
--- /dev/null
+++ b/tests/ui/consts/const-eval/stable-metric/dominators-edge-case.rs
@@ -0,0 +1,19 @@
+// check-pass
+//
+// Exercising an edge case which was found during Stage 2 compilation.
+// Compilation would fail for this code when running the `CtfeLimit`
+// MirPass (specifically when looking up the dominators).
+#![crate_type="lib"]
+
+const DUMMY: Expr = Expr::Path(ExprPath {
+ attrs: Vec::new(),
+ path: Vec::new(),
+});
+
+pub enum Expr {
+ Path(ExprPath),
+}
+pub struct ExprPath {
+ pub attrs: Vec<()>,
+ pub path: Vec<()>,
+}