]> git.lizzy.rs Git - rust.git/commitdiff
Move const-eval/stable-metric ui tests
authorBryan Garza <1396101+bryangarza@users.noreply.github.com>
Tue, 17 Jan 2023 22:35:05 +0000 (22:35 +0000)
committerBryan Garza <1396101+bryangarza@users.noreply.github.com>
Tue, 24 Jan 2023 00:01:40 +0000 (00:01 +0000)
17 files changed:
src/test/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs [deleted file]
src/test/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr [deleted file]
src/test/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs [deleted file]
src/test/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr [deleted file]
src/test/ui/consts/const-eval/stable-metric/ctfe-recursion.rs [deleted file]
src/test/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr [deleted file]
src/test/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs [deleted file]
src/test/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr [deleted file]
tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs [new file with mode: 0644]
tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr [new file with mode: 0644]
tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs [new file with mode: 0644]
tests/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr [new file with mode: 0644]
tests/ui/consts/const-eval/stable-metric/ctfe-recursion.rs [new file with mode: 0644]
tests/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr [new file with mode: 0644]
tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs [new file with mode: 0644]
tests/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr [new file with mode: 0644]
tests/ui/consts/const-eval/stable-metric/dominators-edge-case.rs [new file with mode: 0644]

diff --git a/src/test/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs b/src/test/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs
deleted file mode 100644 (file)
index c595962..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-// 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/src/test/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr b/src/test/ui/consts/const-eval/stable-metric/ctfe-fn-call.stderr
deleted file mode 100644 (file)
index ed70975..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-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/src/test/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs b/src/test/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.rs
deleted file mode 100644 (file)
index c10b8d8..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-// 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/src/test/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr b/src/test/ui/consts/const-eval/stable-metric/ctfe-labelled-loop.stderr
deleted file mode 100644 (file)
index d9404ed..0000000
+++ /dev/null
@@ -1,30 +0,0 @@
-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/src/test/ui/consts/const-eval/stable-metric/ctfe-recursion.rs b/src/test/ui/consts/const-eval/stable-metric/ctfe-recursion.rs
deleted file mode 100644 (file)
index 80ff835..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-// 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/src/test/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr b/src/test/ui/consts/const-eval/stable-metric/ctfe-recursion.stderr
deleted file mode 100644 (file)
index ed9a311..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-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/src/test/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs b/src/test/ui/consts/const-eval/stable-metric/ctfe-simple-loop.rs
deleted file mode 100644 (file)
index ca0eec9..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-// 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/src/test/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr b/src/test/ui/consts/const-eval/stable-metric/ctfe-simple-loop.stderr
deleted file mode 100644 (file)
index 83ff275..0000000
+++ /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-fn-call.rs b/tests/ui/consts/const-eval/stable-metric/ctfe-fn-call.rs
new file mode 100644 (file)
index 0000000..c595962
--- /dev/null
@@ -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 (file)
index 0000000..ed70975
--- /dev/null
@@ -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 (file)
index 0000000..c10b8d8
--- /dev/null
@@ -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 (file)
index 0000000..d9404ed
--- /dev/null
@@ -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 (file)
index 0000000..80ff835
--- /dev/null
@@ -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 (file)
index 0000000..ed9a311
--- /dev/null
@@ -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 (file)
index 0000000..ca0eec9
--- /dev/null
@@ -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 (file)
index 0000000..83ff275
--- /dev/null
@@ -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 (file)
index 0000000..0b0f361
--- /dev/null
@@ -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<()>,
+}