about summary refs log tree commit diff
diff options
context:
space:
mode:
authorOliver Scherer <github35764891676564198441@oli-obk.de>2020-01-08 21:31:08 +0100
committerOliver Scherer <github35764891676564198441@oli-obk.de>2020-01-10 09:08:25 +0100
commitecd5852194f43511443f134aebf0462b58c8e197 (patch)
treeb260b340700e7777d6388ad2c1bf8ffe84e40f7a
parent6e1bbff2c6816236bc3fe0a396c35c405b58fe23 (diff)
downloadrust-ecd5852194f43511443f134aebf0462b58c8e197.tar.gz
rust-ecd5852194f43511443f134aebf0462b58c8e197.zip
Errors in promoteds may only cause lints not hard errors
-rw-r--r--src/librustc_codegen_ssa/mir/constant.rs15
-rw-r--r--src/librustc_mir/transform/const_prop.rs18
-rw-r--r--src/test/run-fail/promoted_div_by_zero.rs (renamed from src/test/compile-fail/promoted_div_by_zero.rs)2
-rw-r--r--src/test/ui/consts/array-literal-index-oob.rs12
-rw-r--r--src/test/ui/consts/array-literal-index-oob.stderr37
-rw-r--r--src/test/ui/consts/const-eval/conditional_array_execution.rs2
-rw-r--r--src/test/ui/consts/const-eval/conditional_array_execution.stderr4
-rw-r--r--src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs6
-rw-r--r--src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr24
-rw-r--r--src/test/ui/consts/const-eval/issue-43197.rs8
-rw-r--r--src/test/ui/consts/const-eval/issue-43197.stderr14
-rw-r--r--src/test/ui/consts/const-eval/issue-44578.rs3
-rw-r--r--src/test/ui/consts/const-eval/issue-44578.stderr8
-rw-r--r--src/test/ui/consts/const-eval/promoted_errors.rs30
-rw-r--r--src/test/ui/consts/const-eval/promoted_errors.stderr55
-rw-r--r--src/test/ui/consts/const-eval/promoted_errors2.rs32
-rw-r--r--src/test/ui/consts/const-eval/promoted_errors2.stderr57
-rw-r--r--src/test/ui/consts/miri_unleashed/non_const_fn.rs2
-rw-r--r--src/test/ui/consts/miri_unleashed/non_const_fn.stderr4
19 files changed, 157 insertions, 176 deletions
diff --git a/src/librustc_codegen_ssa/mir/constant.rs b/src/librustc_codegen_ssa/mir/constant.rs
index c6adbc81ce0..3ce916d7812 100644
--- a/src/librustc_codegen_ssa/mir/constant.rs
+++ b/src/librustc_codegen_ssa/mir/constant.rs
@@ -20,10 +20,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
             // use `get_static` to get at their id.
             // FIXME(oli-obk): can we unify this somehow, maybe by making const eval of statics
             // always produce `&STATIC`. This may also simplify how const eval works with statics.
-            ty::ConstKind::Unevaluated(def_id, substs, promoted)
-                if self.cx.tcx().is_static(def_id) =>
-            {
-                assert!(promoted.is_none());
+            ty::ConstKind::Unevaluated(def_id, substs, None) if self.cx.tcx().is_static(def_id) => {
                 assert!(substs.is_empty(), "we don't support generic statics yet");
                 let static_ = bx.get_static(def_id);
                 // we treat operands referring to statics as if they were `&STATIC` instead
@@ -49,10 +46,12 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
                     .tcx()
                     .const_eval_resolve(ty::ParamEnv::reveal_all(), def_id, substs, promoted, None)
                     .map_err(|err| {
-                        self.cx
-                            .tcx()
-                            .sess
-                            .span_err(constant.span, "erroneous constant encountered");
+                        if promoted.is_none() {
+                            self.cx
+                                .tcx()
+                                .sess
+                                .span_err(constant.span, "erroneous constant encountered");
+                        }
                         err
                     })
             }
diff --git a/src/librustc_mir/transform/const_prop.rs b/src/librustc_mir/transform/const_prop.rs
index b3ef6391097..1d5a643484a 100644
--- a/src/librustc_mir/transform/const_prop.rs
+++ b/src/librustc_mir/transform/const_prop.rs
@@ -18,7 +18,7 @@ use rustc::ty::layout::{
     HasDataLayout, HasTyCtxt, LayoutError, LayoutOf, Size, TargetDataLayout, TyLayout,
 };
 use rustc::ty::subst::{InternalSubsts, Subst};
-use rustc::ty::{self, Instance, ParamEnv, Ty, TyCtxt, TypeFoldable};
+use rustc::ty::{self, ConstKind, Instance, ParamEnv, Ty, TyCtxt, TypeFoldable};
 use rustc_data_structures::fx::FxHashMap;
 use rustc_hir::def::DefKind;
 use rustc_hir::def_id::DefId;
@@ -441,8 +441,15 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
             Ok(op) => Some(op),
             Err(error) => {
                 let err = error_to_const_error(&self.ecx, error);
-                match self.lint_root(source_info) {
-                    Some(lint_root) if c.literal.needs_subst() => {
+                if let Some(lint_root) = self.lint_root(source_info) {
+                    let lint_only = match c.literal.val {
+                        // Promoteds must lint and not error as the user didn't ask for them
+                        ConstKind::Unevaluated(_, _, Some(_)) => true,
+                        // Out of backwards compatibility we cannot report hard errors in unused
+                        // generic functions using associated constants of the generic parameters.
+                        _ => c.literal.needs_subst(),
+                    };
+                    if lint_only {
                         // Out of backwards compatibility we cannot report hard errors in unused
                         // generic functions using associated constants of the generic parameters.
                         err.report_as_lint(
@@ -451,10 +458,11 @@ impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> {
                             lint_root,
                             Some(c.span),
                         );
-                    }
-                    _ => {
+                    } else {
                         err.report_as_error(self.ecx.tcx, "erroneous constant used");
                     }
+                } else {
+                    err.report_as_error(self.ecx.tcx, "erroneous constant used");
                 }
                 None
             }
diff --git a/src/test/compile-fail/promoted_div_by_zero.rs b/src/test/run-fail/promoted_div_by_zero.rs
index de55b5360f3..3fe51a19c20 100644
--- a/src/test/compile-fail/promoted_div_by_zero.rs
+++ b/src/test/run-fail/promoted_div_by_zero.rs
@@ -1,6 +1,6 @@
 #![allow(const_err)]
 
-// error-pattern: referenced constant has errors
+// error-pattern: attempt to divide by zero
 
 fn main() {
     let x = &(1 / (1 - 1));
diff --git a/src/test/ui/consts/array-literal-index-oob.rs b/src/test/ui/consts/array-literal-index-oob.rs
index 59b2fdb7821..64aeb46894d 100644
--- a/src/test/ui/consts/array-literal-index-oob.rs
+++ b/src/test/ui/consts/array-literal-index-oob.rs
@@ -1,8 +1,10 @@
-// build-fail
+// build-pass
+
+#![warn(const_err)]
 
 fn main() {
-    &{[1, 2, 3][4]};
-    //~^ ERROR index out of bounds
-    //~| ERROR reaching this expression at runtime will panic or abort
-    //~| ERROR erroneous constant used [E0080]
+    &{ [1, 2, 3][4] };
+    //~^ WARN index out of bounds
+    //~| WARN reaching this expression at runtime will panic or abort
+    //~| WARN erroneous constant used [const_err]
 }
diff --git a/src/test/ui/consts/array-literal-index-oob.stderr b/src/test/ui/consts/array-literal-index-oob.stderr
index 261c10d1391..50ad8e83e90 100644
--- a/src/test/ui/consts/array-literal-index-oob.stderr
+++ b/src/test/ui/consts/array-literal-index-oob.stderr
@@ -1,25 +1,26 @@
-error: index out of bounds: the len is 3 but the index is 4
-  --> $DIR/array-literal-index-oob.rs:4:7
+warning: index out of bounds: the len is 3 but the index is 4
+  --> $DIR/array-literal-index-oob.rs:6:8
    |
-LL |     &{[1, 2, 3][4]};
-   |       ^^^^^^^^^^^^
+LL |     &{ [1, 2, 3][4] };
+   |        ^^^^^^^^^^^^
    |
-   = note: `#[deny(const_err)]` on by default
-
-error: reaching this expression at runtime will panic or abort
-  --> $DIR/array-literal-index-oob.rs:4:7
+note: lint level defined here
+  --> $DIR/array-literal-index-oob.rs:3:9
    |
-LL |     &{[1, 2, 3][4]};
-   |     --^^^^^^^^^^^^-
-   |       |
-   |       indexing out of bounds: the len is 3 but the index is 4
+LL | #![warn(const_err)]
+   |         ^^^^^^^^^
 
-error[E0080]: erroneous constant used
-  --> $DIR/array-literal-index-oob.rs:4:5
+warning: reaching this expression at runtime will panic or abort
+  --> $DIR/array-literal-index-oob.rs:6:8
    |
-LL |     &{[1, 2, 3][4]};
-   |     ^^^^^^^^^^^^^^^ referenced constant has errors
+LL |     &{ [1, 2, 3][4] };
+   |     ---^^^^^^^^^^^^--
+   |        |
+   |        indexing out of bounds: the len is 3 but the index is 4
 
-error: aborting due to 3 previous errors
+warning: erroneous constant used
+  --> $DIR/array-literal-index-oob.rs:6:5
+   |
+LL |     &{ [1, 2, 3][4] };
+   |     ^^^^^^^^^^^^^^^^^ referenced constant has errors
 
-For more information about this error, try `rustc --explain E0080`.
diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.rs b/src/test/ui/consts/const-eval/conditional_array_execution.rs
index 107d0817daf..2058d2e2184 100644
--- a/src/test/ui/consts/const-eval/conditional_array_execution.rs
+++ b/src/test/ui/consts/const-eval/conditional_array_execution.rs
@@ -10,5 +10,5 @@ const FOO: u32 = [X - Y, Y - X][(X < Y) as usize];
 fn main() {
     println!("{}", FOO);
     //~^ ERROR
-    //~| ERROR erroneous constant used [E0080]
+    //~| WARN erroneous constant used [const_err]
 }
diff --git a/src/test/ui/consts/const-eval/conditional_array_execution.stderr b/src/test/ui/consts/const-eval/conditional_array_execution.stderr
index f161ab6f198..b5f5f84cf38 100644
--- a/src/test/ui/consts/const-eval/conditional_array_execution.stderr
+++ b/src/test/ui/consts/const-eval/conditional_array_execution.stderr
@@ -18,12 +18,12 @@ error[E0080]: evaluation of constant expression failed
 LL |     println!("{}", FOO);
    |                    ^^^ referenced constant has errors
 
-error[E0080]: erroneous constant used
+warning: erroneous constant used
   --> $DIR/conditional_array_execution.rs:11:20
    |
 LL |     println!("{}", FOO);
    |                    ^^^ referenced constant has errors
 
-error: aborting due to 2 previous errors
+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/const_fn_ptr_fail2.rs b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs
index 21dbe72418a..81f53826d81 100644
--- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs
+++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.rs
@@ -4,7 +4,9 @@
 #![feature(const_fn)]
 #![allow(const_err)]
 
-fn double(x: usize) -> usize { x * 2 }
+fn double(x: usize) -> usize {
+    x * 2
+}
 const X: fn(usize) -> usize = double;
 
 const fn bar(x: fn(usize) -> usize, y: usize) -> usize {
@@ -17,8 +19,6 @@ const Z: usize = bar(double, 2); // FIXME: should fail to typeck someday
 fn main() {
     assert_eq!(Y, 4);
     //~^ ERROR evaluation of constant expression failed
-    //~| ERROR erroneous constant used [E0080]
     assert_eq!(Z, 4);
     //~^ ERROR evaluation of constant expression failed
-    //~| ERROR erroneous constant used [E0080]
 }
diff --git a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr
index ebbd18bbd25..f99505c3090 100644
--- a/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr
+++ b/src/test/ui/consts/const-eval/const_fn_ptr_fail2.stderr
@@ -1,11 +1,11 @@
 warning: skipping const checks
-  --> $DIR/const_fn_ptr_fail2.rs:11:5
+  --> $DIR/const_fn_ptr_fail2.rs:13:5
    |
 LL |     x(y)
    |     ^^^^
 
 error[E0080]: evaluation of constant expression failed
-  --> $DIR/const_fn_ptr_fail2.rs:18:5
+  --> $DIR/const_fn_ptr_fail2.rs:20:5
    |
 LL |     assert_eq!(Y, 4);
    |     ^^^^^^^^^^^-^^^^^
@@ -14,16 +14,8 @@ LL |     assert_eq!(Y, 4);
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
 
-error[E0080]: erroneous constant used
-  --> $DIR/const_fn_ptr_fail2.rs:18:5
-   |
-LL |     assert_eq!(Y, 4);
-   |     ^^^^^^^^^^^^^^^^^ referenced constant has errors
-   |
-   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-
 error[E0080]: evaluation of constant expression failed
-  --> $DIR/const_fn_ptr_fail2.rs:21:5
+  --> $DIR/const_fn_ptr_fail2.rs:22:5
    |
 LL |     assert_eq!(Z, 4);
    |     ^^^^^^^^^^^-^^^^^
@@ -32,14 +24,6 @@ LL |     assert_eq!(Z, 4);
    |
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
 
-error[E0080]: erroneous constant used
-  --> $DIR/const_fn_ptr_fail2.rs:21:5
-   |
-LL |     assert_eq!(Z, 4);
-   |     ^^^^^^^^^^^^^^^^^ referenced constant has errors
-   |
-   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)
-
-error: aborting due to 4 previous errors
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0080`.
diff --git a/src/test/ui/consts/const-eval/issue-43197.rs b/src/test/ui/consts/const-eval/issue-43197.rs
index 23890be6934..9109307632b 100644
--- a/src/test/ui/consts/const-eval/issue-43197.rs
+++ b/src/test/ui/consts/const-eval/issue-43197.rs
@@ -7,13 +7,13 @@ const fn foo(x: u32) -> u32 {
 }
 
 fn main() {
-    const X: u32 = 0-1;
+    const X: u32 = 0 - 1;
     //~^ WARN any use of this value will cause
-    const Y: u32 = foo(0-1);
+    const Y: u32 = foo(0 - 1);
     //~^ WARN any use of this value will cause
     println!("{} {}", X, Y);
     //~^ ERROR evaluation of constant expression failed
     //~| ERROR evaluation of constant expression failed
-    //~| ERROR erroneous constant used [E0080]
-    //~| ERROR erroneous constant used [E0080]
+    //~| WARN erroneous constant used [const_err]
+    //~| WARN erroneous constant used [const_err]
 }
diff --git a/src/test/ui/consts/const-eval/issue-43197.stderr b/src/test/ui/consts/const-eval/issue-43197.stderr
index 50bc07d459c..23b54d954c6 100644
--- a/src/test/ui/consts/const-eval/issue-43197.stderr
+++ b/src/test/ui/consts/const-eval/issue-43197.stderr
@@ -1,8 +1,8 @@
 warning: any use of this value will cause an error
   --> $DIR/issue-43197.rs:10:20
    |
-LL |     const X: u32 = 0-1;
-   |     ---------------^^^-
+LL |     const X: u32 = 0 - 1;
+   |     ---------------^^^^^-
    |                    |
    |                    attempt to subtract with overflow
    |
@@ -15,8 +15,8 @@ LL | #![warn(const_err)]
 warning: any use of this value will cause an error
   --> $DIR/issue-43197.rs:12:24
    |
-LL |     const Y: u32 = foo(0-1);
-   |     -------------------^^^--
+LL |     const Y: u32 = foo(0 - 1);
+   |     -------------------^^^^^--
    |                        |
    |                        attempt to subtract with overflow
 
@@ -26,7 +26,7 @@ error[E0080]: evaluation of constant expression failed
 LL |     println!("{} {}", X, Y);
    |                       ^ referenced constant has errors
 
-error[E0080]: erroneous constant used
+warning: erroneous constant used
   --> $DIR/issue-43197.rs:14:23
    |
 LL |     println!("{} {}", X, Y);
@@ -38,12 +38,12 @@ error[E0080]: evaluation of constant expression failed
 LL |     println!("{} {}", X, Y);
    |                          ^ referenced constant has errors
 
-error[E0080]: erroneous constant used
+warning: erroneous constant used
   --> $DIR/issue-43197.rs:14:26
    |
 LL |     println!("{} {}", X, Y);
    |                          ^ referenced constant has errors
 
-error: aborting due to 4 previous errors
+error: aborting due to 2 previous errors
 
 For more information about this error, try `rustc --explain E0080`.
diff --git a/src/test/ui/consts/const-eval/issue-44578.rs b/src/test/ui/consts/const-eval/issue-44578.rs
index 607f78f70b3..f9194709dc0 100644
--- a/src/test/ui/consts/const-eval/issue-44578.rs
+++ b/src/test/ui/consts/const-eval/issue-44578.rs
@@ -25,6 +25,5 @@ impl Foo for u16 {
 
 fn main() {
     println!("{}", <Bar<u16, u8> as Foo>::AMT);
-    //~^ ERROR erroneous constant used [E0080]
-    //~| ERROR evaluation of constant expression failed [E0080]
+    //~^ ERROR evaluation of constant expression failed [E0080]
 }
diff --git a/src/test/ui/consts/const-eval/issue-44578.stderr b/src/test/ui/consts/const-eval/issue-44578.stderr
index 5c0ac17aceb..f4323713e68 100644
--- a/src/test/ui/consts/const-eval/issue-44578.stderr
+++ b/src/test/ui/consts/const-eval/issue-44578.stderr
@@ -4,12 +4,6 @@ error[E0080]: evaluation of constant expression failed
 LL |     println!("{}", <Bar<u16, u8> as Foo>::AMT);
    |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
 
-error[E0080]: erroneous constant used
-  --> $DIR/issue-44578.rs:27:20
-   |
-LL |     println!("{}", <Bar<u16, u8> as Foo>::AMT);
-   |                    ^^^^^^^^^^^^^^^^^^^^^^^^^^ referenced constant has errors
-
-error: aborting due to 2 previous errors
+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/promoted_errors.rs b/src/test/ui/consts/const-eval/promoted_errors.rs
index 6d83839a8d1..fee232185d2 100644
--- a/src/test/ui/consts/const-eval/promoted_errors.rs
+++ b/src/test/ui/consts/const-eval/promoted_errors.rs
@@ -1,22 +1,22 @@
-// build-fail
+// build-pass
 // compile-flags: -O
 
-#![deny(const_err)]
+#![warn(const_err)]
 
 fn main() {
     println!("{}", 0u32 - 1);
     let _x = 0u32 - 1;
-    //~^ ERROR const_err
-    println!("{}", 1/(1-1));
-    //~^ ERROR attempt to divide by zero [const_err]
-    //~| ERROR const_err
-    //~| ERROR erroneous constant used [E0080]
-    let _x = 1/(1-1);
-    //~^ ERROR const_err
-    println!("{}", 1/(false as u32));
-    //~^ ERROR attempt to divide by zero [const_err]
-    //~| ERROR const_err
-    //~| ERROR erroneous constant used [E0080]
-    let _x = 1/(false as u32);
-    //~^ ERROR const_err
+    //~^ WARN const_err
+    println!("{}", 1 / (1 - 1));
+    //~^ WARN attempt to divide by zero [const_err]
+    //~| WARN const_err
+    //~| WARN erroneous constant used [const_err]
+    let _x = 1 / (1 - 1);
+    //~^ WARN const_err
+    println!("{}", 1 / (false as u32));
+    //~^ WARN attempt to divide by zero [const_err]
+    //~| WARN const_err
+    //~| WARN erroneous constant used [const_err]
+    let _x = 1 / (false as u32);
+    //~^ WARN const_err
 }
diff --git a/src/test/ui/consts/const-eval/promoted_errors.stderr b/src/test/ui/consts/const-eval/promoted_errors.stderr
index 32672ca8566..4de22fdf4ab 100644
--- a/src/test/ui/consts/const-eval/promoted_errors.stderr
+++ b/src/test/ui/consts/const-eval/promoted_errors.stderr
@@ -1,4 +1,4 @@
-error: this expression will panic at runtime
+warning: this expression will panic at runtime
   --> $DIR/promoted_errors.rs:8:14
    |
 LL |     let _x = 0u32 - 1;
@@ -7,57 +7,54 @@ LL |     let _x = 0u32 - 1;
 note: lint level defined here
   --> $DIR/promoted_errors.rs:4:9
    |
-LL | #![deny(const_err)]
+LL | #![warn(const_err)]
    |         ^^^^^^^^^
 
-error: attempt to divide by zero
+warning: attempt to divide by zero
   --> $DIR/promoted_errors.rs:10:20
    |
-LL |     println!("{}", 1/(1-1));
-   |                    ^^^^^^^
+LL |     println!("{}", 1 / (1 - 1));
+   |                    ^^^^^^^^^^^
 
-error: reaching this expression at runtime will panic or abort
+warning: reaching this expression at runtime will panic or abort
   --> $DIR/promoted_errors.rs:10:20
    |
-LL |     println!("{}", 1/(1-1));
-   |                    ^^^^^^^ dividing by zero
+LL |     println!("{}", 1 / (1 - 1));
+   |                    ^^^^^^^^^^^ dividing by zero
 
-error[E0080]: erroneous constant used
+warning: erroneous constant used
   --> $DIR/promoted_errors.rs:10:20
    |
-LL |     println!("{}", 1/(1-1));
-   |                    ^^^^^^^ referenced constant has errors
+LL |     println!("{}", 1 / (1 - 1));
+   |                    ^^^^^^^^^^^ referenced constant has errors
 
-error: attempt to divide by zero
+warning: attempt to divide by zero
   --> $DIR/promoted_errors.rs:14:14
    |
-LL |     let _x = 1/(1-1);
-   |              ^^^^^^^
+LL |     let _x = 1 / (1 - 1);
+   |              ^^^^^^^^^^^
 
-error: attempt to divide by zero
+warning: attempt to divide by zero
   --> $DIR/promoted_errors.rs:16:20
    |
-LL |     println!("{}", 1/(false as u32));
-   |                    ^^^^^^^^^^^^^^^^
+LL |     println!("{}", 1 / (false as u32));
+   |                    ^^^^^^^^^^^^^^^^^^
 
-error: reaching this expression at runtime will panic or abort
+warning: reaching this expression at runtime will panic or abort
   --> $DIR/promoted_errors.rs:16:20
    |
-LL |     println!("{}", 1/(false as u32));
-   |                    ^^^^^^^^^^^^^^^^ dividing by zero
+LL |     println!("{}", 1 / (false as u32));
+   |                    ^^^^^^^^^^^^^^^^^^ dividing by zero
 
-error[E0080]: erroneous constant used
+warning: erroneous constant used
   --> $DIR/promoted_errors.rs:16:20
    |
-LL |     println!("{}", 1/(false as u32));
-   |                    ^^^^^^^^^^^^^^^^ referenced constant has errors
+LL |     println!("{}", 1 / (false as u32));
+   |                    ^^^^^^^^^^^^^^^^^^ referenced constant has errors
 
-error: attempt to divide by zero
+warning: attempt to divide by zero
   --> $DIR/promoted_errors.rs:20:14
    |
-LL |     let _x = 1/(false as u32);
-   |              ^^^^^^^^^^^^^^^^
+LL |     let _x = 1 / (false as u32);
+   |              ^^^^^^^^^^^^^^^^^^
 
-error: aborting due to 9 previous errors
-
-For more information about this error, try `rustc --explain E0080`.
diff --git a/src/test/ui/consts/const-eval/promoted_errors2.rs b/src/test/ui/consts/const-eval/promoted_errors2.rs
index 8ea6cdf6a8f..41a989d91c5 100644
--- a/src/test/ui/consts/const-eval/promoted_errors2.rs
+++ b/src/test/ui/consts/const-eval/promoted_errors2.rs
@@ -1,23 +1,23 @@
-// build-fail
+// build-pass
 // compile-flags: -C overflow-checks=on -O
 
-#![deny(const_err)]
+#![warn(const_err)]
 
 fn main() {
     println!("{}", 0u32 - 1);
-    //~^ ERROR attempt to subtract with overflow
+    //~^ WARN attempt to subtract with overflow
     let _x = 0u32 - 1;
-    //~^ ERROR attempt to subtract with overflow
-    println!("{}", 1/(1-1));
-    //~^ ERROR attempt to divide by zero [const_err]
-    //~| ERROR const_err
-    //~| ERROR erroneous constant used [E0080]
-    let _x = 1/(1-1);
-    //~^ ERROR const_err
-    println!("{}", 1/(false as u32));
-    //~^ ERROR attempt to divide by zero [const_err]
-    //~| ERROR const_err
-    //~| ERROR erroneous constant used [E0080]
-    let _x = 1/(false as u32);
-    //~^ ERROR const_err
+    //~^ WARN attempt to subtract with overflow
+    println!("{}", 1 / (1 - 1));
+    //~^ WARN attempt to divide by zero [const_err]
+    //~| WARN const_err
+    //~| WARN erroneous constant used [const_err]
+    let _x = 1 / (1 - 1);
+    //~^ WARN const_err
+    println!("{}", 1 / (false as u32));
+    //~^ WARN attempt to divide by zero [const_err]
+    //~| WARN const_err
+    //~| WARN erroneous constant used [const_err]
+    let _x = 1 / (false as u32);
+    //~^ WARN const_err
 }
diff --git a/src/test/ui/consts/const-eval/promoted_errors2.stderr b/src/test/ui/consts/const-eval/promoted_errors2.stderr
index e7a73aa8118..4f7ba8bf385 100644
--- a/src/test/ui/consts/const-eval/promoted_errors2.stderr
+++ b/src/test/ui/consts/const-eval/promoted_errors2.stderr
@@ -1,4 +1,4 @@
-error: attempt to subtract with overflow
+warning: attempt to subtract with overflow
   --> $DIR/promoted_errors2.rs:7:20
    |
 LL |     println!("{}", 0u32 - 1);
@@ -7,63 +7,60 @@ LL |     println!("{}", 0u32 - 1);
 note: lint level defined here
   --> $DIR/promoted_errors2.rs:4:9
    |
-LL | #![deny(const_err)]
+LL | #![warn(const_err)]
    |         ^^^^^^^^^
 
-error: attempt to subtract with overflow
+warning: attempt to subtract with overflow
   --> $DIR/promoted_errors2.rs:9:14
    |
 LL |     let _x = 0u32 - 1;
    |              ^^^^^^^^
 
-error: attempt to divide by zero
+warning: attempt to divide by zero
   --> $DIR/promoted_errors2.rs:11:20
    |
-LL |     println!("{}", 1/(1-1));
-   |                    ^^^^^^^
+LL |     println!("{}", 1 / (1 - 1));
+   |                    ^^^^^^^^^^^
 
-error: reaching this expression at runtime will panic or abort
+warning: reaching this expression at runtime will panic or abort
   --> $DIR/promoted_errors2.rs:11:20
    |
-LL |     println!("{}", 1/(1-1));
-   |                    ^^^^^^^ dividing by zero
+LL |     println!("{}", 1 / (1 - 1));
+   |                    ^^^^^^^^^^^ dividing by zero
 
-error[E0080]: erroneous constant used
+warning: erroneous constant used
   --> $DIR/promoted_errors2.rs:11:20
    |
-LL |     println!("{}", 1/(1-1));
-   |                    ^^^^^^^ referenced constant has errors
+LL |     println!("{}", 1 / (1 - 1));
+   |                    ^^^^^^^^^^^ referenced constant has errors
 
-error: attempt to divide by zero
+warning: attempt to divide by zero
   --> $DIR/promoted_errors2.rs:15:14
    |
-LL |     let _x = 1/(1-1);
-   |              ^^^^^^^
+LL |     let _x = 1 / (1 - 1);
+   |              ^^^^^^^^^^^
 
-error: attempt to divide by zero
+warning: attempt to divide by zero
   --> $DIR/promoted_errors2.rs:17:20
    |
-LL |     println!("{}", 1/(false as u32));
-   |                    ^^^^^^^^^^^^^^^^
+LL |     println!("{}", 1 / (false as u32));
+   |                    ^^^^^^^^^^^^^^^^^^
 
-error: reaching this expression at runtime will panic or abort
+warning: reaching this expression at runtime will panic or abort
   --> $DIR/promoted_errors2.rs:17:20
    |
-LL |     println!("{}", 1/(false as u32));
-   |                    ^^^^^^^^^^^^^^^^ dividing by zero
+LL |     println!("{}", 1 / (false as u32));
+   |                    ^^^^^^^^^^^^^^^^^^ dividing by zero
 
-error[E0080]: erroneous constant used
+warning: erroneous constant used
   --> $DIR/promoted_errors2.rs:17:20
    |
-LL |     println!("{}", 1/(false as u32));
-   |                    ^^^^^^^^^^^^^^^^ referenced constant has errors
+LL |     println!("{}", 1 / (false as u32));
+   |                    ^^^^^^^^^^^^^^^^^^ referenced constant has errors
 
-error: attempt to divide by zero
+warning: attempt to divide by zero
   --> $DIR/promoted_errors2.rs:21:14
    |
-LL |     let _x = 1/(false as u32);
-   |              ^^^^^^^^^^^^^^^^
+LL |     let _x = 1 / (false as u32);
+   |              ^^^^^^^^^^^^^^^^^^
 
-error: aborting due to 10 previous errors
-
-For more information about this error, try `rustc --explain E0080`.
diff --git a/src/test/ui/consts/miri_unleashed/non_const_fn.rs b/src/test/ui/consts/miri_unleashed/non_const_fn.rs
index 23b0cfa8321..cfb57d21cee 100644
--- a/src/test/ui/consts/miri_unleashed/non_const_fn.rs
+++ b/src/test/ui/consts/miri_unleashed/non_const_fn.rs
@@ -13,5 +13,5 @@ const C: () = foo(); //~ WARN: skipping const checks
 fn main() {
     println!("{:?}", C);
     //~^ ERROR: evaluation of constant expression failed
-    //~| ERROR: erroneous constant used [E0080]
+    //~| WARN: erroneous constant used [const_err]
 }
diff --git a/src/test/ui/consts/miri_unleashed/non_const_fn.stderr b/src/test/ui/consts/miri_unleashed/non_const_fn.stderr
index a7364ddf72c..6a7df858feb 100644
--- a/src/test/ui/consts/miri_unleashed/non_const_fn.stderr
+++ b/src/test/ui/consts/miri_unleashed/non_const_fn.stderr
@@ -24,12 +24,12 @@ error[E0080]: evaluation of constant expression failed
 LL |     println!("{:?}", C);
    |                      ^ referenced constant has errors
 
-error[E0080]: erroneous constant used
+warning: erroneous constant used
   --> $DIR/non_const_fn.rs:14:22
    |
 LL |     println!("{:?}", C);
    |                      ^ referenced constant has errors
 
-error: aborting due to 2 previous errors
+error: aborting due to previous error
 
 For more information about this error, try `rustc --explain E0080`.