]> git.lizzy.rs Git - rust.git/commitdiff
Update const-eval tests
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Tue, 17 Mar 2020 23:08:28 +0000 (16:08 -0700)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Wed, 18 Mar 2020 03:27:49 +0000 (20:27 -0700)
src/test/ui/consts/const-eval/infinite_loop.rs
src/test/ui/consts/const-eval/infinite_loop.stderr
src/test/ui/consts/const-eval/issue-52475.rs
src/test/ui/consts/const-eval/issue-52475.stderr
src/test/ui/consts/const_limit/const_eval_limit_not_reached.rs
src/test/ui/consts/const_limit/const_eval_limit_reached.rs
src/test/ui/consts/const_limit/const_eval_limit_reached.stderr

index af5e7658d48d2641f572ac9839d48d895d40add4..c8de259354eac03f0d79f73d45b5a4a2bbe79238 100644 (file)
@@ -2,7 +2,6 @@ fn main() {
     // Tests the Collatz conjecture with an incorrect base case (0 instead of 1).
     // The value of `n` will loop indefinitely (4 - 2 - 1 - 4).
     let _ = [(); {
-        //~^ WARNING Constant evaluating a complex constant, this might take some time
         let mut n = 113383; // #20 in https://oeis.org/A006884
         while n != 0 {
         //~^ ERROR `while` is not allowed in a `const`
index e04c31cf397821d8463aa71ef786742f88e45e81..9b56457ea5f5743dcd222abeff2171cc15ebe435 100644 (file)
@@ -1,5 +1,5 @@
 error[E0658]: `while` is not allowed in a `const`
-  --> $DIR/infinite_loop.rs:7:9
+  --> $DIR/infinite_loop.rs:6:9
    |
 LL | /         while n != 0 {
 LL | |
@@ -14,7 +14,7 @@ LL | |         }
    = help: add `#![feature(const_if_match)]` to the crate attributes to enable
 
 error[E0658]: `if` is not allowed in a `const`
-  --> $DIR/infinite_loop.rs:9:17
+  --> $DIR/infinite_loop.rs:8:17
    |
 LL |             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -22,24 +22,11 @@ LL |             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
    = note: see issue #49146 <https://github.com/rust-lang/rust/issues/49146> for more information
    = help: add `#![feature(const_if_match)]` to the crate attributes to enable
 
-warning: Constant evaluating a complex constant, this might take some time
-  --> $DIR/infinite_loop.rs:4:18
-   |
-LL |       let _ = [(); {
-   |  __________________^
-LL | |
-LL | |         let mut n = 113383; // #20 in https://oeis.org/A006884
-LL | |         while n != 0 {
-...  |
-LL | |         n
-LL | |     }];
-   | |_____^
-
 error[E0080]: evaluation of constant value failed
-  --> $DIR/infinite_loop.rs:9:20
+  --> $DIR/infinite_loop.rs:8:20
    |
 LL |             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
-   |                    ^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
+   |                    ^^^^^^^^^^ exceeded interpreter time limit
 
 error: aborting due to 3 previous errors
 
index 3788167f4490248f7b87b188bddc2a537b4d9417..869f0b981af7d881e4dce06fc6f4cd9fe531b727 100644 (file)
@@ -1,6 +1,5 @@
 fn main() {
     let _ = [(); {
-        //~^ WARNING Constant evaluating a complex constant, this might take some time
         let mut x = &0;
         let mut n = 0;
         while n < 5 {
index 31d87925b2cfcdd40414bb5d559b477591c7b8a7..8d6168a7f86938db44208b851d459fde38f3be7b 100644 (file)
@@ -1,5 +1,5 @@
 error[E0658]: `while` is not allowed in a `const`
-  --> $DIR/issue-52475.rs:6:9
+  --> $DIR/issue-52475.rs:5:9
    |
 LL | /         while n < 5 {
 LL | |
@@ -12,24 +12,11 @@ LL | |         }
    = help: add `#![feature(const_loop)]` to the crate attributes to enable
    = help: add `#![feature(const_if_match)]` to the crate attributes to enable
 
-warning: Constant evaluating a complex constant, this might take some time
-  --> $DIR/issue-52475.rs:2:18
-   |
-LL |       let _ = [(); {
-   |  __________________^
-LL | |
-LL | |         let mut x = &0;
-LL | |         let mut n = 0;
-...  |
-LL | |         0
-LL | |     }];
-   | |_____^
-
 error[E0080]: evaluation of constant value failed
-  --> $DIR/issue-52475.rs:8:17
+  --> $DIR/issue-52475.rs:7:17
    |
 LL |             n = (n + 1) % 5;
-   |                 ^^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
+   |                 ^^^^^^^^^^^ exceeded interpreter time limit
 
 error: aborting due to 2 previous errors
 
index 4ed908312fb6dcc11a58fb72d96b7f5bd9b98780..34abcdf08dae0e2cf6159f5a3af2e04ae2b8b79a 100644 (file)
@@ -1,15 +1,21 @@
 // check-pass
+
 #![feature(const_eval_limit)]
-#![const_eval_limit="1000"]
+#![feature(const_loop, const_if_match)]
 
-const CONSTANT: usize = 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"]
 
-fn main() {
-    assert_eq!(CONSTANT, 1764);
-}
+const X: usize = {
+    let mut x = 0;
+    while x != 1000 {
+        x += 1;
+    }
 
-const fn limit() -> usize {
-    let x = 42;
+    x
+};
 
-    x * 42
+fn main() {
+    assert_eq!(X, 1000);
 }
index d962398d4136e7d04517191b3cb8cf42f5bbc8f4..b45aca0b13e42f51a1f2f7299555cfdb76530cab 100644 (file)
@@ -1,21 +1,18 @@
-// ignore-tidy-linelength
-// only-x86_64
-// check-pass
-// NOTE: We always compile this test with -Copt-level=0 because higher opt-levels
-//       optimize away the const function
-// compile-flags:-Copt-level=0
 #![feature(const_eval_limit)]
-#![const_eval_limit="2"]
+#![feature(const_loop, const_if_match)]
 
-const CONSTANT: usize = limit();
-//~^ WARNING Constant evaluating a complex constant, this might take some time
+#![const_eval_limit="500"]
 
-fn main() {
-    assert_eq!(CONSTANT, 1764);
-}
+const X: usize = {
+    let mut x = 0;
+    while x != 1000 {
+        //~^ ERROR any use of this value will cause an error
+        x += 1;
+    }
 
-const fn limit() -> usize { //~ WARNING Constant evaluating a complex constant, this might take some time
-    let x = 42;
+    x
+};
 
-    x * 42
+fn main() {
+    assert_eq!(X, 1000);
 }
index e0871ff718561f9d8220ed0dea4da6166844cfa3..ca8fbef9072d85ac3d473c5d6dccf5737ca4a385 100644 (file)
@@ -1,16 +1,17 @@
-warning: Constant evaluating a complex constant, this might take some time
-  --> $DIR/const_eval_limit_reached.rs:17:1
+error: any use of this value will cause an error
+  --> $DIR/const_eval_limit_reached.rs:8:11
    |
-LL | / const fn limit() -> usize {
-LL | |     let x = 42;
+LL | / const X: usize = {
+LL | |     let mut x = 0;
+LL | |     while x != 1000 {
+   | |           ^^^^^^^^^ exceeded interpreter time limit
 LL | |
-LL | |     x * 42
-LL | | }
-   | |_^
-
-warning: Constant evaluating a complex constant, this might take some time
-  --> $DIR/const_eval_limit_reached.rs:10:1
+...  |
+LL | |     x
+LL | | };
+   | |__-
    |
-LL | const CONSTANT: usize = limit();
-   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+   = note: `#[deny(const_err)]` on by default
+
+error: aborting due to previous error