about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2019-11-09 09:29:57 -0800
committerDylan MacKenzie <ecstaticmorse@gmail.com>2019-11-13 10:44:14 -0800
commit86734b13bb99c83333ca820e01be3aeace18af75 (patch)
treee779309119eb4200aab8e4e276386e72bac926eb
parent70aa781c2d8f4ebe0e826d2cdeb8fcd371676a88 (diff)
downloadrust-86734b13bb99c83333ca820e01be3aeace18af75.tar.gz
rust-86734b13bb99c83333ca820e01be3aeace18af75.zip
Bless less verbose error messages
The MIR const-checker errors for if/match/loop are now delay span bugs,
so nothing will be emitted unless the HIR checker misses something.
-rw-r--r--src/test/compile-fail/consts/const-fn-error.rs2
-rw-r--r--src/test/compile-fail/issue-52443.rs6
-rw-r--r--src/test/ui/consts/const-eval/infinite_loop.rs4
-rw-r--r--src/test/ui/consts/const-eval/infinite_loop.stderr31
-rw-r--r--src/test/ui/consts/const-eval/issue-52475.rs2
-rw-r--r--src/test/ui/consts/const-eval/issue-52475.stderr28
-rw-r--r--src/test/ui/consts/const-eval/match-test-ptr-null.rs3
-rw-r--r--src/test/ui/consts/const-eval/match-test-ptr-null.stderr20
-rw-r--r--src/test/ui/consts/const-loop.rs2
-rw-r--r--src/test/ui/consts/const-loop.stderr37
-rw-r--r--src/test/ui/consts/miri_unleashed/enum_discriminants.stderr43
-rw-r--r--src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs6
-rw-r--r--src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr52
13 files changed, 68 insertions, 168 deletions
diff --git a/src/test/compile-fail/consts/const-fn-error.rs b/src/test/compile-fail/consts/const-fn-error.rs
index 6f414dab88e..4adad16a570 100644
--- a/src/test/compile-fail/consts/const-fn-error.rs
+++ b/src/test/compile-fail/consts/const-fn-error.rs
@@ -7,8 +7,6 @@ const fn f(x: usize) -> usize {
     for i in 0..x {
         //~^ ERROR E0015
         //~| ERROR E0017
-        //~| ERROR E0019
-        //~| ERROR E0019
         //~| ERROR E0080
         //~| ERROR E0744
         sum += i;
diff --git a/src/test/compile-fail/issue-52443.rs b/src/test/compile-fail/issue-52443.rs
index 90b9a1c265a..04eecb5687f 100644
--- a/src/test/compile-fail/issue-52443.rs
+++ b/src/test/compile-fail/issue-52443.rs
@@ -4,15 +4,11 @@ fn main() {
     [(); loop { break }]; //~ ERROR mismatched types
     //~^ ERROR `loop` is not allowed in a `const`
     [(); {while true {break}; 0}];
-    //~^ ERROR constant contains unimplemented expression type
-    //~| ERROR constant contains unimplemented expression type
-    //~| ERROR `while` is not allowed in a `const`
+    //~^ ERROR `while` is not allowed in a `const`
     //~| WARN denote infinite loops with
     [(); { for _ in 0usize.. {}; 0}];
     //~^ ERROR calls in constants are limited to constant functions
     //~| ERROR `for` is not allowed in a `const`
     //~| ERROR references in constants may only refer to immutable values
-    //~| ERROR constant contains unimplemented expression type
-    //~| ERROR constant contains unimplemented expression type
     //~| ERROR evaluation of constant value failed
 }
diff --git a/src/test/ui/consts/const-eval/infinite_loop.rs b/src/test/ui/consts/const-eval/infinite_loop.rs
index ee1d588e553..af5e7658d48 100644
--- a/src/test/ui/consts/const-eval/infinite_loop.rs
+++ b/src/test/ui/consts/const-eval/infinite_loop.rs
@@ -5,9 +5,7 @@ fn main() {
         //~^ 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 constant contains unimplemented expression type
-        //~| ERROR constant contains unimplemented expression type
-        //~| ERROR `while` is not allowed in a `const`
+        //~^ ERROR `while` is not allowed in a `const`
             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
             //~^ ERROR evaluation of constant value failed
             //~| ERROR `if` is not allowed in a `const`
diff --git a/src/test/ui/consts/const-eval/infinite_loop.stderr b/src/test/ui/consts/const-eval/infinite_loop.stderr
index bf5d2c8c328..2af6af95c55 100644
--- a/src/test/ui/consts/const-eval/infinite_loop.stderr
+++ b/src/test/ui/consts/const-eval/infinite_loop.stderr
@@ -3,37 +3,18 @@ error[E0744]: `while` is not allowed in a `const`
    |
 LL | /         while n != 0 {
 LL | |
+LL | |             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
 LL | |
 LL | |
-...  |
-LL | |
 LL | |         }
    | |_________^
 
 error[E0744]: `if` is not allowed in a `const`
-  --> $DIR/infinite_loop.rs:11:17
+  --> $DIR/infinite_loop.rs:9:17
    |
 LL |             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
    |                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/infinite_loop.rs:7:15
-   |
-LL |         while n != 0 {
-   |               ^^^^^^
-
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/infinite_loop.rs:7:9
-   |
-LL | /         while n != 0 {
-LL | |
-LL | |
-LL | |
-...  |
-LL | |
-LL | |         }
-   | |_________^
-
 warning: Constant evaluating a complex constant, this might take some time
   --> $DIR/infinite_loop.rs:4:18
    |
@@ -48,12 +29,12 @@ LL | |     }];
    | |_____^
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/infinite_loop.rs:11:20
+  --> $DIR/infinite_loop.rs:9:20
    |
 LL |             n = if n % 2 == 0 { n/2 } else { 3*n + 1 };
    |                    ^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
 
-error: aborting due to 5 previous errors
+error: aborting due to 3 previous errors
 
-Some errors have detailed explanations: E0019, E0080, E0744.
-For more information about an error, try `rustc --explain E0019`.
+Some errors have detailed explanations: E0080, E0744.
+For more information about an error, try `rustc --explain E0080`.
diff --git a/src/test/ui/consts/const-eval/issue-52475.rs b/src/test/ui/consts/const-eval/issue-52475.rs
index b9cdf09b85f..3788167f449 100644
--- a/src/test/ui/consts/const-eval/issue-52475.rs
+++ b/src/test/ui/consts/const-eval/issue-52475.rs
@@ -5,8 +5,6 @@ fn main() {
         let mut n = 0;
         while n < 5 {
         //~^ ERROR `while` is not allowed in a `const`
-        //~| ERROR constant contains unimplemented expression type
-        //~| ERROR constant contains unimplemented expression type
             n = (n + 1) % 5; //~ ERROR evaluation of constant value failed
             x = &0; // Materialize a new AllocId
         }
diff --git a/src/test/ui/consts/const-eval/issue-52475.stderr b/src/test/ui/consts/const-eval/issue-52475.stderr
index 25d56e3fac4..b8267f495de 100644
--- a/src/test/ui/consts/const-eval/issue-52475.stderr
+++ b/src/test/ui/consts/const-eval/issue-52475.stderr
@@ -3,26 +3,6 @@ error[E0744]: `while` is not allowed in a `const`
    |
 LL | /         while n < 5 {
 LL | |
-LL | |
-LL | |
-LL | |             n = (n + 1) % 5;
-LL | |             x = &0; // Materialize a new AllocId
-LL | |         }
-   | |_________^
-
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/issue-52475.rs:6:15
-   |
-LL |         while n < 5 {
-   |               ^^^^^
-
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/issue-52475.rs:6:9
-   |
-LL | /         while n < 5 {
-LL | |
-LL | |
-LL | |
 LL | |             n = (n + 1) % 5;
 LL | |             x = &0; // Materialize a new AllocId
 LL | |         }
@@ -42,12 +22,12 @@ LL | |     }];
    | |_____^
 
 error[E0080]: evaluation of constant value failed
-  --> $DIR/issue-52475.rs:10:17
+  --> $DIR/issue-52475.rs:8:17
    |
 LL |             n = (n + 1) % 5;
    |                 ^^^^^^^^^^^ duplicate interpreter state observed here, const evaluation will never terminate
 
-error: aborting due to 4 previous errors
+error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0019, E0080, E0744.
-For more information about an error, try `rustc --explain E0019`.
+Some errors have detailed explanations: E0080, E0744.
+For more information about an error, try `rustc --explain E0080`.
diff --git a/src/test/ui/consts/const-eval/match-test-ptr-null.rs b/src/test/ui/consts/const-eval/match-test-ptr-null.rs
index 0dc3652bbee..80494d16629 100644
--- a/src/test/ui/consts/const-eval/match-test-ptr-null.rs
+++ b/src/test/ui/consts/const-eval/match-test-ptr-null.rs
@@ -6,9 +6,8 @@ fn main() {
         match &1 as *const i32 as usize {
             //~^ ERROR casting pointers to integers in constants
             //~| ERROR `match` is not allowed in a `const`
-            //~| ERROR constant contains unimplemented expression type
             //~| ERROR evaluation of constant value failed
-            0 => 42, //~ ERROR constant contains unimplemented expression type
+            0 => 42,
             n => n,
         }
     }];
diff --git a/src/test/ui/consts/const-eval/match-test-ptr-null.stderr b/src/test/ui/consts/const-eval/match-test-ptr-null.stderr
index ab4d28c0455..587dca4c1f2 100644
--- a/src/test/ui/consts/const-eval/match-test-ptr-null.stderr
+++ b/src/test/ui/consts/const-eval/match-test-ptr-null.stderr
@@ -5,7 +5,7 @@ LL | /         match &1 as *const i32 as usize {
 LL | |
 LL | |
 LL | |
-...  |
+LL | |             0 => 42,
 LL | |             n => n,
 LL | |         }
    | |_________^
@@ -19,25 +19,13 @@ LL |         match &1 as *const i32 as usize {
    = note: for more information, see https://github.com/rust-lang/rust/issues/51910
    = help: add `#![feature(const_raw_ptr_to_usize_cast)]` to the crate attributes to enable
 
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/match-test-ptr-null.rs:6:15
-   |
-LL |         match &1 as *const i32 as usize {
-   |               ^^^^^^^^^^^^^^^^^^^^^^^^^
-
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/match-test-ptr-null.rs:11:13
-   |
-LL |             0 => 42,
-   |             ^
-
 error[E0080]: evaluation of constant value failed
   --> $DIR/match-test-ptr-null.rs:6:15
    |
 LL |         match &1 as *const i32 as usize {
    |               ^^^^^^^^^^^^^^^^^^^^^^^^^ "pointer-to-integer cast" needs an rfc before being allowed inside constants
 
-error: aborting due to 5 previous errors
+error: aborting due to 3 previous errors
 
-Some errors have detailed explanations: E0019, E0080, E0658, E0744.
-For more information about an error, try `rustc --explain E0019`.
+Some errors have detailed explanations: E0080, E0658, E0744.
+For more information about an error, try `rustc --explain E0080`.
diff --git a/src/test/ui/consts/const-loop.rs b/src/test/ui/consts/const-loop.rs
index 383db24ad63..b0fe5e320f4 100644
--- a/src/test/ui/consts/const-loop.rs
+++ b/src/test/ui/consts/const-loop.rs
@@ -30,8 +30,6 @@ fn main() {
     let x = [0; {
         while false {}
         //~^ ERROR `while` is not allowed in a `const`
-        //~| ERROR constant contains unimplemented expression type
-        //~| ERROR constant contains unimplemented expression type
         4
     }];
 }
diff --git a/src/test/ui/consts/const-loop.stderr b/src/test/ui/consts/const-loop.stderr
index bfb953547d3..2c96d181759 100644
--- a/src/test/ui/consts/const-loop.stderr
+++ b/src/test/ui/consts/const-loop.stderr
@@ -29,7 +29,7 @@ LL |         while false {}
    |         ^^^^^^^^^^^^^^
 
 error[E0744]: `while` is not allowed in a `const`
-  --> $DIR/const-loop.rs:42:5
+  --> $DIR/const-loop.rs:40:5
    |
 LL | /     while x < 4 {
 LL | |         x += 1;
@@ -37,7 +37,7 @@ LL | |     }
    | |_____^
 
 error[E0744]: `while` is not allowed in a `const`
-  --> $DIR/const-loop.rs:46:5
+  --> $DIR/const-loop.rs:44:5
    |
 LL | /     while x < 8 {
 LL | |         x += 1;
@@ -45,7 +45,7 @@ LL | |     }
    | |_____^
 
 error[E0744]: `for` is not allowed in a `const`
-  --> $DIR/const-loop.rs:56:5
+  --> $DIR/const-loop.rs:54:5
    |
 LL | /     for i in 0..4 {
 LL | |         x += i;
@@ -53,7 +53,7 @@ LL | |     }
    | |_____^
 
 error[E0744]: `for` is not allowed in a `const`
-  --> $DIR/const-loop.rs:60:5
+  --> $DIR/const-loop.rs:58:5
    |
 LL | /     for i in 0..4 {
 LL | |         x += i;
@@ -61,7 +61,7 @@ LL | |     }
    | |_____^
 
 error[E0744]: `loop` is not allowed in a `const`
-  --> $DIR/const-loop.rs:70:5
+  --> $DIR/const-loop.rs:68:5
    |
 LL | /     loop {
 LL | |         x += 1;
@@ -72,7 +72,7 @@ LL | |     }
    | |_____^
 
 error[E0744]: `if` is not allowed in a `const`
-  --> $DIR/const-loop.rs:72:9
+  --> $DIR/const-loop.rs:70:9
    |
 LL | /         if x == 4 {
 LL | |             break;
@@ -80,7 +80,7 @@ LL | |         }
    | |_________^
 
 error[E0744]: `loop` is not allowed in a `const`
-  --> $DIR/const-loop.rs:77:5
+  --> $DIR/const-loop.rs:75:5
    |
 LL | /     loop {
 LL | |         x += 1;
@@ -91,7 +91,7 @@ LL | |     }
    | |_____^
 
 error[E0744]: `if` is not allowed in a `const`
-  --> $DIR/const-loop.rs:79:9
+  --> $DIR/const-loop.rs:77:9
    |
 LL | /         if x == 8 {
 LL | |             break;
@@ -99,13 +99,13 @@ LL | |         }
    | |_________^
 
 error[E0744]: `while let` is not allowed in a `const`
-  --> $DIR/const-loop.rs:89:5
+  --> $DIR/const-loop.rs:87:5
    |
 LL |     while let None = Some(x) { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
 
 error[E0744]: `while let` is not allowed in a `const`
-  --> $DIR/const-loop.rs:90:5
+  --> $DIR/const-loop.rs:88:5
    |
 LL |     while let None = Some(x) { }
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -122,19 +122,6 @@ error[E0744]: `loop` is not allowed in a `const`
 LL |     const BAR: i32 = loop { break 4; };
    |                      ^^^^^^^^^^^^^^^^^
 
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/const-loop.rs:31:15
-   |
-LL |         while false {}
-   |               ^^^^^
-
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/const-loop.rs:31:9
-   |
-LL |         while false {}
-   |         ^^^^^^^^^^^^^^
-
-error: aborting due to 19 previous errors
+error: aborting due to 17 previous errors
 
-Some errors have detailed explanations: E0019, E0744.
-For more information about an error, try `rustc --explain E0019`.
+For more information about this error, try `rustc --explain E0744`.
diff --git a/src/test/ui/consts/miri_unleashed/enum_discriminants.stderr b/src/test/ui/consts/miri_unleashed/enum_discriminants.stderr
index df366ba22e4..38eeb327135 100644
--- a/src/test/ui/consts/miri_unleashed/enum_discriminants.stderr
+++ b/src/test/ui/consts/miri_unleashed/enum_discriminants.stderr
@@ -1,24 +1,43 @@
 warning: skipping const checks
-  --> $DIR/enum_discriminants.rs:23:13
+  --> $DIR/enum_discriminants.rs:24:5
    |
-LL |     let x = Foo::B;
-   |             ^^^^^^
+LL | /     match x {
+LL | |         Foo::B => 0,
+LL | |         _ => panic!(),
+LL | |     }
+   | |_____^
 
 warning: skipping const checks
-  --> $DIR/enum_discriminants.rs:25:9
+  --> $DIR/enum_discriminants.rs:88:5
    |
-LL |         Foo::B => 0,
-   |         ^^^^^^
+LL | /     if let E1::V2 { .. } = (E1::V1 { f: true }) {
+LL | |         unreachable!()
+LL | |     }
+   | |_____^
 
 warning: skipping const checks
-  --> $DIR/enum_discriminants.rs:88:28
+  --> $DIR/enum_discriminants.rs:91:5
    |
-LL |     if let E1::V2 { .. } = (E1::V1 { f: true }) {
-   |                            ^^^^^^^^^^^^^^^^^^^^
+LL | /     if let E1::V1 { .. } = (E1::V1 { f: true }) {
+LL | |     } else {
+LL | |         unreachable!()
+LL | |     }
+   | |_____^
 
 warning: skipping const checks
-  --> $DIR/enum_discriminants.rs:88:12
+  --> $DIR/enum_discriminants.rs:96:5
    |
-LL |     if let E1::V2 { .. } = (E1::V1 { f: true }) {
-   |            ^^^^^^^^^^^^^
+LL | /     if let E2::V1 { .. } = E2::V3::<Infallible> {
+LL | |         unreachable!()
+LL | |     }
+   | |_____^
+
+warning: skipping const checks
+  --> $DIR/enum_discriminants.rs:99:5
+   |
+LL | /     if let E2::V3 { .. } = E2::V3::<Infallible> {
+LL | |     } else {
+LL | |         unreachable!()
+LL | |     }
+   | |_____^
 
diff --git a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs
index 3baa19b5aed..d5756737f17 100644
--- a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs
+++ b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.rs
@@ -216,22 +216,16 @@ fn inside_const_generic_arguments() {
 
     if let A::<{
         true && let 1 = 1 //~ ERROR `let` expressions are not supported here
-        //~^ ERROR constant contains unimplemented expression type
-        //~| ERROR constant contains unimplemented expression type
         //~| ERROR `match` is not allowed in a `const`
     }>::O = 5 {}
 
     while let A::<{
         true && let 1 = 1 //~ ERROR `let` expressions are not supported here
-        //~^ ERROR constant contains unimplemented expression type
-        //~| ERROR constant contains unimplemented expression type
         //~| ERROR `match` is not allowed in a `const`
     }>::O = 5 {}
 
     if A::<{
         true && let 1 = 1 //~ ERROR `let` expressions are not supported here
-        //~^ ERROR constant contains unimplemented expression type
-        //~| ERROR constant contains unimplemented expression type
         //~| ERROR `match` is not allowed in a `const`
     }>::O == 5 {}
 
diff --git a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr
index 92cdead7856..aa7c342819e 100644
--- a/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr
+++ b/src/test/ui/rfc-2497-if-let-chains/disallowed-positions.stderr
@@ -1,5 +1,5 @@
 error: expected one of `,` or `>`, found `&&`
-  --> $DIR/disallowed-positions.rs:245:14
+  --> $DIR/disallowed-positions.rs:239:14
    |
 LL |         true && let 1 = 1
    |              ^^ expected one of `,` or `>`
@@ -482,7 +482,7 @@ LL |         true && let 1 = 1
    = note: as well as when nested within `&&` and parenthesis in those conditions
 
 error: `let` expressions are not supported here
-  --> $DIR/disallowed-positions.rs:225:17
+  --> $DIR/disallowed-positions.rs:223:17
    |
 LL |         true && let 1 = 1
    |                 ^^^^^^^^^
@@ -491,7 +491,7 @@ LL |         true && let 1 = 1
    = note: as well as when nested within `&&` and parenthesis in those conditions
 
 error: `let` expressions are not supported here
-  --> $DIR/disallowed-positions.rs:232:17
+  --> $DIR/disallowed-positions.rs:228:17
    |
 LL |         true && let 1 = 1
    |                 ^^^^^^^^^
@@ -520,13 +520,13 @@ LL |         true && let 1 = 1
    |                 ^^^^^^^^^
 
 error[E0744]: `match` is not allowed in a `const`
-  --> $DIR/disallowed-positions.rs:225:17
+  --> $DIR/disallowed-positions.rs:223:17
    |
 LL |         true && let 1 = 1
    |                 ^^^^^^^^^
 
 error[E0744]: `match` is not allowed in a `const`
-  --> $DIR/disallowed-positions.rs:232:17
+  --> $DIR/disallowed-positions.rs:228:17
    |
 LL |         true && let 1 = 1
    |                 ^^^^^^^^^
@@ -971,43 +971,7 @@ LL |         let 0 = 0?;
    = help: the trait `std::ops::Try` is not implemented for `{integer}`
    = note: required by `std::ops::Try::into_result`
 
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/disallowed-positions.rs:218:25
-   |
-LL |         true && let 1 = 1
-   |                         ^
-
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/disallowed-positions.rs:218:21
-   |
-LL |         true && let 1 = 1
-   |                     ^
-
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/disallowed-positions.rs:225:25
-   |
-LL |         true && let 1 = 1
-   |                         ^
-
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/disallowed-positions.rs:225:21
-   |
-LL |         true && let 1 = 1
-   |                     ^
-
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/disallowed-positions.rs:232:25
-   |
-LL |         true && let 1 = 1
-   |                         ^
-
-error[E0019]: constant contains unimplemented expression type
-  --> $DIR/disallowed-positions.rs:232:21
-   |
-LL |         true && let 1 = 1
-   |                     ^
-
-error: aborting due to 112 previous errors
+error: aborting due to 106 previous errors
 
-Some errors have detailed explanations: E0019, E0277, E0308, E0600, E0614, E0744.
-For more information about an error, try `rustc --explain E0019`.
+Some errors have detailed explanations: E0277, E0308, E0600, E0614, E0744.
+For more information about an error, try `rustc --explain E0277`.