about summary refs log tree commit diff
diff options
context:
space:
mode:
authorChristian Poveda <git@christianpoveda.xyz>2020-06-15 12:05:24 -0500
committerChristian Poveda <git@christianpoveda.xyz>2020-06-19 11:48:46 -0500
commit1f48465a0147769cfe6487212862a66518663fed (patch)
tree608e581f7c1a2d0112dcc000824a52407dc00e3f
parent014e60587070dea266ae9133b879a9ef3409208b (diff)
downloadrust-1f48465a0147769cfe6487212862a66518663fed.tar.gz
rust-1f48465a0147769cfe6487212862a66518663fed.zip
update diagnostics for &mut in constants
-rw-r--r--src/librustc_mir/transform/check_consts/ops.rs28
-rw-r--r--src/test/compile-fail/issue-52443.rs2
-rw-r--r--src/test/ui/check-static-immutable-mut-slices.rs2
-rw-r--r--src/test/ui/check-static-immutable-mut-slices.stderr9
-rw-r--r--src/test/ui/consts/const-eval/issue-65394.rs2
-rw-r--r--src/test/ui/consts/const-eval/issue-65394.stderr11
-rw-r--r--src/test/ui/consts/const-multi-ref.rs2
-rw-r--r--src/test/ui/consts/const-multi-ref.stderr11
-rw-r--r--src/test/ui/consts/const-mut-refs/const_mut_address_of.rs4
-rw-r--r--src/test/ui/consts/const-mut-refs/const_mut_address_of.stderr16
-rw-r--r--src/test/ui/consts/const-mut-refs/const_mut_refs.rs6
-rw-r--r--src/test/ui/consts/const-mut-refs/const_mut_refs.stderr23
-rw-r--r--src/test/ui/consts/const_let_assign3.rs4
-rw-r--r--src/test/ui/consts/const_let_assign3.stderr17
-rw-r--r--src/test/ui/consts/projection_qualif.mut_refs.stderr10
-rw-r--r--src/test/ui/consts/projection_qualif.rs2
-rw-r--r--src/test/ui/consts/projection_qualif.stock.stderr7
-rw-r--r--src/test/ui/consts/read_from_static_mut_ref.rs3
-rw-r--r--src/test/ui/consts/read_from_static_mut_ref.stderr11
-rw-r--r--src/test/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr9
-rw-r--r--src/test/ui/consts/static_mut_containing_mut_ref2.rs2
-rw-r--r--src/test/ui/consts/static_mut_containing_mut_ref2.stock.stderr10
-rw-r--r--src/test/ui/error-codes/E0017.rs8
-rw-r--r--src/test/ui/error-codes/E0017.stderr30
-rw-r--r--src/test/ui/error-codes/E0388.rs6
-rw-r--r--src/test/ui/error-codes/E0388.stderr23
-rw-r--r--src/test/ui/issues/issue-17718-const-bad-values.rs4
-rw-r--r--src/test/ui/issues/issue-17718-const-bad-values.stderr16
-rw-r--r--src/test/ui/issues/issue-46604.rs2
-rw-r--r--src/test/ui/issues/issue-46604.stderr11
30 files changed, 111 insertions, 180 deletions
diff --git a/src/librustc_mir/transform/check_consts/ops.rs b/src/librustc_mir/transform/check_consts/ops.rs
index 39095d13ded..5e3bd2c1d3d 100644
--- a/src/librustc_mir/transform/check_consts/ops.rs
+++ b/src/librustc_mir/transform/check_consts/ops.rs
@@ -216,17 +216,23 @@ impl NonConstOp for MutBorrow {
     }
 
     fn emit_error(&self, ccx: &ConstCx<'_, '_>, span: Span) {
-        let mut err = feature_err(
-            &ccx.tcx.sess.parse_sess,
-            sym::const_mut_refs,
-            span,
-            &format!(
-                "references in {}s may only refer \
-                      to immutable values",
-                ccx.const_kind()
-            ),
-        );
-        err.span_label(span, format!("{}s require immutable values", ccx.const_kind()));
+        let mut err = if ccx.const_kind() == hir::ConstContext::ConstFn {
+            feature_err(
+                &ccx.tcx.sess.parse_sess,
+                sym::const_mut_refs,
+                span,
+                &format!("mutable references are not allowed in {}s", ccx.const_kind()),
+            )
+        } else {
+            struct_span_err!(
+                ccx.tcx.sess,
+                span,
+                E0019,
+                "mutable references are not allowed in {}s",
+                ccx.const_kind(),
+            )
+        };
+        err.span_label(span, "`&mut` is only allowed in `const fn`".to_string());
         if ccx.tcx.sess.teach(&err.get_code().unwrap()) {
             err.note(
                 "References in statics and constants may only refer \
diff --git a/src/test/compile-fail/issue-52443.rs b/src/test/compile-fail/issue-52443.rs
index 97619593352..00aca1d14ba 100644
--- a/src/test/compile-fail/issue-52443.rs
+++ b/src/test/compile-fail/issue-52443.rs
@@ -9,7 +9,7 @@ fn main() {
     [(); { for _ in 0usize.. {}; 0}];
     //~^ ERROR `for` is not allowed in a `const`
     //~| ERROR calls in constants are limited to constant functions
-    //~| ERROR references in constants may only refer to immutable values
+    //~| ERROR mutable references are not allowed in constants
     //~| ERROR calls in constants are limited to constant functions
     //~| ERROR evaluation of constant value failed
 }
diff --git a/src/test/ui/check-static-immutable-mut-slices.rs b/src/test/ui/check-static-immutable-mut-slices.rs
index d5e9fb2dede..3be02f6a0f6 100644
--- a/src/test/ui/check-static-immutable-mut-slices.rs
+++ b/src/test/ui/check-static-immutable-mut-slices.rs
@@ -1,6 +1,6 @@
 // Checks that immutable static items can't have mutable slices
 
 static TEST: &'static mut [isize] = &mut [];
-//~^ ERROR references in statics may only refer to immutable values
+//~^ ERROR mutable references are not allowed in statics
 
 pub fn main() { }
diff --git a/src/test/ui/check-static-immutable-mut-slices.stderr b/src/test/ui/check-static-immutable-mut-slices.stderr
index 66fe8646e10..855f6dda182 100644
--- a/src/test/ui/check-static-immutable-mut-slices.stderr
+++ b/src/test/ui/check-static-immutable-mut-slices.stderr
@@ -1,12 +1,9 @@
-error[E0658]: references in statics may only refer to immutable values
+error[E0019]: mutable references are not allowed in statics
   --> $DIR/check-static-immutable-mut-slices.rs:3:37
    |
 LL | static TEST: &'static mut [isize] = &mut [];
-   |                                     ^^^^^^^ statics require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                                     ^^^^^^^ `&mut` is only allowed in `const fn`
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0658`.
+For more information about this error, try `rustc --explain E0019`.
diff --git a/src/test/ui/consts/const-eval/issue-65394.rs b/src/test/ui/consts/const-eval/issue-65394.rs
index b1c058eac9e..2518e4ed40b 100644
--- a/src/test/ui/consts/const-eval/issue-65394.rs
+++ b/src/test/ui/consts/const-eval/issue-65394.rs
@@ -5,7 +5,7 @@
 
 const _: Vec<i32> = {
     let mut x = Vec::<i32>::new(); //~ ERROR destructors cannot be evaluated at compile-time
-    let r = &mut x; //~ ERROR references in constants may only refer to immutable values
+    let r = &mut x; //~ ERROR mutable references are not allowed in constants
     let y = x;
     y
 };
diff --git a/src/test/ui/consts/const-eval/issue-65394.stderr b/src/test/ui/consts/const-eval/issue-65394.stderr
index d85a1a1a3c3..827af6d832d 100644
--- a/src/test/ui/consts/const-eval/issue-65394.stderr
+++ b/src/test/ui/consts/const-eval/issue-65394.stderr
@@ -1,11 +1,8 @@
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/issue-65394.rs:8:13
    |
 LL |     let r = &mut x;
-   |             ^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |             ^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0493]: destructors cannot be evaluated at compile-time
   --> $DIR/issue-65394.rs:7:9
@@ -15,5 +12,5 @@ LL |     let mut x = Vec::<i32>::new();
 
 error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0493, E0658.
-For more information about an error, try `rustc --explain E0493`.
+Some errors have detailed explanations: E0019, E0493.
+For more information about an error, try `rustc --explain E0019`.
diff --git a/src/test/ui/consts/const-multi-ref.rs b/src/test/ui/consts/const-multi-ref.rs
index 5e2be0d4f3f..18645efc887 100644
--- a/src/test/ui/consts/const-multi-ref.rs
+++ b/src/test/ui/consts/const-multi-ref.rs
@@ -3,7 +3,7 @@
 
 const _: i32 = {
     let mut a = 5;
-    let p = &mut a; //~ ERROR references in constants may only refer to immutable values
+    let p = &mut a; //~ ERROR mutable references are not allowed in constants
 
     let reborrow = {p};
     let pp = &reborrow;
diff --git a/src/test/ui/consts/const-multi-ref.stderr b/src/test/ui/consts/const-multi-ref.stderr
index e01dd4e5747..84ff5457eef 100644
--- a/src/test/ui/consts/const-multi-ref.stderr
+++ b/src/test/ui/consts/const-multi-ref.stderr
@@ -1,11 +1,8 @@
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/const-multi-ref.rs:6:13
    |
 LL |     let p = &mut a;
-   |             ^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |             ^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0492]: cannot borrow a constant which may contain interior mutability, create a static instead
   --> $DIR/const-multi-ref.rs:16:13
@@ -15,5 +12,5 @@ LL |     let p = &a;
 
 error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0492, E0658.
-For more information about an error, try `rustc --explain E0492`.
+Some errors have detailed explanations: E0019, E0492.
+For more information about an error, try `rustc --explain E0019`.
diff --git a/src/test/ui/consts/const-mut-refs/const_mut_address_of.rs b/src/test/ui/consts/const-mut-refs/const_mut_address_of.rs
index c6660d2f29f..5819daa817a 100644
--- a/src/test/ui/consts/const-mut-refs/const_mut_address_of.rs
+++ b/src/test/ui/consts/const-mut-refs/const_mut_address_of.rs
@@ -22,9 +22,9 @@ const fn baz(foo: &mut Foo)-> *mut usize {
 
 const _: () = {
     foo().bar();
-    //~^ ERROR references in constants may only refer to immutable values
+    //~^ ERROR mutable references are not allowed in constants
     baz(&mut foo());
-    //~^ ERROR references in constants may only refer to immutable values
+    //~^ ERROR mutable references are not allowed in constants
 };
 
 fn main() {}
diff --git a/src/test/ui/consts/const-mut-refs/const_mut_address_of.stderr b/src/test/ui/consts/const-mut-refs/const_mut_address_of.stderr
index f4af69701e3..3940ce236a3 100644
--- a/src/test/ui/consts/const-mut-refs/const_mut_address_of.stderr
+++ b/src/test/ui/consts/const-mut-refs/const_mut_address_of.stderr
@@ -1,21 +1,15 @@
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/const_mut_address_of.rs:24:5
    |
 LL |     foo().bar();
-   |     ^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |     ^^^^^ `&mut` is only allowed in `const fn`
 
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/const_mut_address_of.rs:26:9
    |
 LL |     baz(&mut foo());
-   |         ^^^^^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |         ^^^^^^^^^^ `&mut` is only allowed in `const fn`
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0658`.
+For more information about this error, try `rustc --explain E0019`.
diff --git a/src/test/ui/consts/const-mut-refs/const_mut_refs.rs b/src/test/ui/consts/const-mut-refs/const_mut_refs.rs
index ddcd94f9db9..9099d5a1b8e 100644
--- a/src/test/ui/consts/const-mut-refs/const_mut_refs.rs
+++ b/src/test/ui/consts/const-mut-refs/const_mut_refs.rs
@@ -29,9 +29,9 @@ const fn bazz(foo: &mut Foo) -> usize {
 
 fn main() {
     let _: [(); foo().bar()] = [(); 1];
-    //~^ ERROR references in constants may only refer to immutable values
+    //~^ ERROR mutable references are not allowed in constants
     let _: [(); baz(&mut foo())] = [(); 2];
-    //~^ ERROR references in constants may only refer to immutable values
+    //~^ ERROR mutable references are not allowed in constants
     let _: [(); bazz(&mut foo())] = [(); 3];
-    //~^ ERROR references in constants may only refer to immutable values
+    //~^ ERROR mutable references are not allowed in constants
 }
diff --git a/src/test/ui/consts/const-mut-refs/const_mut_refs.stderr b/src/test/ui/consts/const-mut-refs/const_mut_refs.stderr
index b2aa577ae67..39d0a391bab 100644
--- a/src/test/ui/consts/const-mut-refs/const_mut_refs.stderr
+++ b/src/test/ui/consts/const-mut-refs/const_mut_refs.stderr
@@ -1,30 +1,21 @@
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/const_mut_refs.rs:31:17
    |
 LL |     let _: [(); foo().bar()] = [(); 1];
-   |                 ^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                 ^^^^^ `&mut` is only allowed in `const fn`
 
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/const_mut_refs.rs:33:21
    |
 LL |     let _: [(); baz(&mut foo())] = [(); 2];
-   |                     ^^^^^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                     ^^^^^^^^^^ `&mut` is only allowed in `const fn`
 
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/const_mut_refs.rs:35:22
    |
 LL |     let _: [(); bazz(&mut foo())] = [(); 3];
-   |                      ^^^^^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                      ^^^^^^^^^^ `&mut` is only allowed in `const fn`
 
 error: aborting due to 3 previous errors
 
-For more information about this error, try `rustc --explain E0658`.
+For more information about this error, try `rustc --explain E0019`.
diff --git a/src/test/ui/consts/const_let_assign3.rs b/src/test/ui/consts/const_let_assign3.rs
index cbe73923e9c..f993a427b48 100644
--- a/src/test/ui/consts/const_let_assign3.rs
+++ b/src/test/ui/consts/const_let_assign3.rs
@@ -13,14 +13,14 @@ impl S {
 
 const FOO: S = {
     let mut s = S { state: 42 };
-    s.foo(3); //~ ERROR references in constants may only refer to immutable values
+    s.foo(3); //~ ERROR mutable references are not allowed in constants
     s
 };
 
 type Array = [u32; {
     let mut x = 2;
     let y = &mut x;
-//~^ ERROR references in constants may only refer to immutable values
+//~^ ERROR mutable references are not allowed in constants
     *y = 42;
 //~^ ERROR constant contains unimplemented expression type
     *y
diff --git a/src/test/ui/consts/const_let_assign3.stderr b/src/test/ui/consts/const_let_assign3.stderr
index 62fd04ea522..a5810e60a09 100644
--- a/src/test/ui/consts/const_let_assign3.stderr
+++ b/src/test/ui/consts/const_let_assign3.stderr
@@ -6,23 +6,17 @@ LL |         self.state = x;
    |
    = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
 
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/const_let_assign3.rs:16:5
    |
 LL |     s.foo(3);
-   |     ^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |     ^ `&mut` is only allowed in `const fn`
 
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/const_let_assign3.rs:22:13
    |
 LL |     let y = &mut x;
-   |             ^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |             ^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0019]: constant contains unimplemented expression type
   --> $DIR/const_let_assign3.rs:24:5
@@ -34,5 +28,4 @@ LL |     *y = 42;
 
 error: aborting due to 4 previous errors
 
-Some errors have detailed explanations: E0019, E0658.
-For more information about an error, try `rustc --explain E0019`.
+For more information about this error, try `rustc --explain E0019`.
diff --git a/src/test/ui/consts/projection_qualif.mut_refs.stderr b/src/test/ui/consts/projection_qualif.mut_refs.stderr
index 9d6ec0a115f..e84c86f5a78 100644
--- a/src/test/ui/consts/projection_qualif.mut_refs.stderr
+++ b/src/test/ui/consts/projection_qualif.mut_refs.stderr
@@ -1,11 +1,8 @@
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/projection_qualif.rs:10:27
    |
 LL |         let b: *mut u32 = &mut a;
-   |                           ^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                           ^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0658]: dereferencing raw pointers in constants is unstable
   --> $DIR/projection_qualif.rs:11:18
@@ -18,4 +15,5 @@ LL |         unsafe { *b = 5; }
 
 error: aborting due to 2 previous errors
 
-For more information about this error, try `rustc --explain E0658`.
+Some errors have detailed explanations: E0019, E0658.
+For more information about an error, try `rustc --explain E0019`.
diff --git a/src/test/ui/consts/projection_qualif.rs b/src/test/ui/consts/projection_qualif.rs
index 52fb1106a33..7db970cf137 100644
--- a/src/test/ui/consts/projection_qualif.rs
+++ b/src/test/ui/consts/projection_qualif.rs
@@ -7,7 +7,7 @@ use std::cell::Cell;
 const FOO: &u32 = {
     let mut a = 42;
     {
-        let b: *mut u32 = &mut a; //~ ERROR may only refer to immutable values
+        let b: *mut u32 = &mut a; //~ ERROR mutable references are not allowed in constants
         unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants
         //[stock]~^ contains unimplemented expression
     }
diff --git a/src/test/ui/consts/projection_qualif.stock.stderr b/src/test/ui/consts/projection_qualif.stock.stderr
index cfa48d947c9..01e12e186fe 100644
--- a/src/test/ui/consts/projection_qualif.stock.stderr
+++ b/src/test/ui/consts/projection_qualif.stock.stderr
@@ -1,11 +1,8 @@
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/projection_qualif.rs:10:27
    |
 LL |         let b: *mut u32 = &mut a;
-   |                           ^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                           ^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0658]: dereferencing raw pointers in constants is unstable
   --> $DIR/projection_qualif.rs:11:18
diff --git a/src/test/ui/consts/read_from_static_mut_ref.rs b/src/test/ui/consts/read_from_static_mut_ref.rs
index beb2c3f075d..5faa983ab09 100644
--- a/src/test/ui/consts/read_from_static_mut_ref.rs
+++ b/src/test/ui/consts/read_from_static_mut_ref.rs
@@ -1,8 +1,9 @@
+// We are keeping this test in case we decide to allow mutable references in statics again
 #![feature(const_mut_refs)]
 #![allow(const_err)]
 
 static OH_NO: &mut i32 = &mut 42;
-//~^ ERROR references in statics may only refer to immutable values
+//~^ ERROR mutable references are not allowed in statics
 fn main() {
     assert_eq!(*OH_NO, 42);
 }
diff --git a/src/test/ui/consts/read_from_static_mut_ref.stderr b/src/test/ui/consts/read_from_static_mut_ref.stderr
index 7e37eaa9cfa..c51ddae23d8 100644
--- a/src/test/ui/consts/read_from_static_mut_ref.stderr
+++ b/src/test/ui/consts/read_from_static_mut_ref.stderr
@@ -1,12 +1,9 @@
-error[E0658]: references in statics may only refer to immutable values
-  --> $DIR/read_from_static_mut_ref.rs:4:26
+error[E0019]: mutable references are not allowed in statics
+  --> $DIR/read_from_static_mut_ref.rs:5:26
    |
 LL | static OH_NO: &mut i32 = &mut 42;
-   |                          ^^^^^^^ statics require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                          ^^^^^^^ `&mut` is only allowed in `const fn`
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0658`.
+For more information about this error, try `rustc --explain E0019`.
diff --git a/src/test/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr b/src/test/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr
index ab0b7c2b6d4..2c6abb3a4ed 100644
--- a/src/test/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr
+++ b/src/test/ui/consts/static_mut_containing_mut_ref2.mut_refs.stderr
@@ -1,12 +1,9 @@
-error[E0658]: references in statics may only refer to immutable values
+error[E0019]: mutable references are not allowed in statics
   --> $DIR/static_mut_containing_mut_ref2.rs:7:46
    |
 LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
-   |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^ statics require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^ `&mut` is only allowed in `const fn`
 
 error: aborting due to previous error
 
-For more information about this error, try `rustc --explain E0658`.
+For more information about this error, try `rustc --explain E0019`.
diff --git a/src/test/ui/consts/static_mut_containing_mut_ref2.rs b/src/test/ui/consts/static_mut_containing_mut_ref2.rs
index 8f2ea83c505..a6bbe8d6ec2 100644
--- a/src/test/ui/consts/static_mut_containing_mut_ref2.rs
+++ b/src/test/ui/consts/static_mut_containing_mut_ref2.rs
@@ -5,7 +5,7 @@
 static mut STDERR_BUFFER_SPACE: u8 = 0;
 
 pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
-//~^ ERROR references in statics may only refer to immutable values
+//~^ ERROR  mutable references are not allowed in statics
 //[stock]~| ERROR static contains unimplemented expression type
 
 fn main() {}
diff --git a/src/test/ui/consts/static_mut_containing_mut_ref2.stock.stderr b/src/test/ui/consts/static_mut_containing_mut_ref2.stock.stderr
index cc169351bf2..47c9401704c 100644
--- a/src/test/ui/consts/static_mut_containing_mut_ref2.stock.stderr
+++ b/src/test/ui/consts/static_mut_containing_mut_ref2.stock.stderr
@@ -1,11 +1,8 @@
-error[E0658]: references in statics may only refer to immutable values
+error[E0019]: mutable references are not allowed in statics
   --> $DIR/static_mut_containing_mut_ref2.rs:7:46
    |
 LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
-   |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^ statics require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                                              ^^^^^^^^^^^^^^^^^^^^^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0019]: static contains unimplemented expression type
   --> $DIR/static_mut_containing_mut_ref2.rs:7:45
@@ -17,5 +14,4 @@ LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 4
 
 error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0019, E0658.
-For more information about an error, try `rustc --explain E0019`.
+For more information about this error, try `rustc --explain E0019`.
diff --git a/src/test/ui/error-codes/E0017.rs b/src/test/ui/error-codes/E0017.rs
index 64be41170d0..8e6de93f440 100644
--- a/src/test/ui/error-codes/E0017.rs
+++ b/src/test/ui/error-codes/E0017.rs
@@ -2,10 +2,10 @@ static X: i32 = 1;
 const C: i32 = 2;
 static mut M: i32 = 3;
 
-const CR: &'static mut i32 = &mut C; //~ ERROR E0658
-static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0658
+const CR: &'static mut i32 = &mut C; //~ ERROR E0019
+static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0019
                                               //~| ERROR E0019
                                               //~| ERROR cannot borrow
-static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0658
-static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; //~ ERROR E0658
+static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0019
+static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; //~ ERROR E0019
 fn main() {}
diff --git a/src/test/ui/error-codes/E0017.stderr b/src/test/ui/error-codes/E0017.stderr
index f959ad0d008..d952afa2521 100644
--- a/src/test/ui/error-codes/E0017.stderr
+++ b/src/test/ui/error-codes/E0017.stderr
@@ -1,11 +1,8 @@
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/E0017.rs:5:30
    |
 LL | const CR: &'static mut i32 = &mut C;
-   |                              ^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                              ^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0019]: static contains unimplemented expression type
   --> $DIR/E0017.rs:6:39
@@ -15,14 +12,11 @@ LL | static STATIC_REF: &'static mut i32 = &mut X;
    |
    = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
 
-error[E0658]: references in statics may only refer to immutable values
+error[E0019]: mutable references are not allowed in statics
   --> $DIR/E0017.rs:6:39
    |
 LL | static STATIC_REF: &'static mut i32 = &mut X;
-   |                                       ^^^^^^ statics require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                                       ^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0596]: cannot borrow immutable static item `X` as mutable
   --> $DIR/E0017.rs:6:39
@@ -30,25 +24,19 @@ error[E0596]: cannot borrow immutable static item `X` as mutable
 LL | static STATIC_REF: &'static mut i32 = &mut X;
    |                                       ^^^^^^ cannot borrow as mutable
 
-error[E0658]: references in statics may only refer to immutable values
+error[E0019]: mutable references are not allowed in statics
   --> $DIR/E0017.rs:9:38
    |
 LL | static CONST_REF: &'static mut i32 = &mut C;
-   |                                      ^^^^^^ statics require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                                      ^^^^^^ `&mut` is only allowed in `const fn`
 
-error[E0658]: references in statics may only refer to immutable values
+error[E0019]: mutable references are not allowed in statics
   --> $DIR/E0017.rs:10:52
    |
 LL | static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M };
-   |                                                    ^^^^^^ statics require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                                                    ^^^^^^ `&mut` is only allowed in `const fn`
 
 error: aborting due to 6 previous errors
 
-Some errors have detailed explanations: E0019, E0596, E0658.
+Some errors have detailed explanations: E0019, E0596.
 For more information about an error, try `rustc --explain E0019`.
diff --git a/src/test/ui/error-codes/E0388.rs b/src/test/ui/error-codes/E0388.rs
index 5954e3490b0..90ea8649b8b 100644
--- a/src/test/ui/error-codes/E0388.rs
+++ b/src/test/ui/error-codes/E0388.rs
@@ -1,10 +1,10 @@
 static X: i32 = 1;
 const C: i32 = 2;
 
-const CR: &'static mut i32 = &mut C; //~ ERROR E0658
-static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0658
+const CR: &'static mut i32 = &mut C; //~ ERROR E0019
+static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0019
                                               //~| ERROR cannot borrow
                                               //~| ERROR E0019
-static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0658
+static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0019
 
 fn main() {}
diff --git a/src/test/ui/error-codes/E0388.stderr b/src/test/ui/error-codes/E0388.stderr
index 8bdfbac3681..04b3d954250 100644
--- a/src/test/ui/error-codes/E0388.stderr
+++ b/src/test/ui/error-codes/E0388.stderr
@@ -1,11 +1,8 @@
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/E0388.rs:4:30
    |
 LL | const CR: &'static mut i32 = &mut C;
-   |                              ^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                              ^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0019]: static contains unimplemented expression type
   --> $DIR/E0388.rs:5:39
@@ -15,14 +12,11 @@ LL | static STATIC_REF: &'static mut i32 = &mut X;
    |
    = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
 
-error[E0658]: references in statics may only refer to immutable values
+error[E0019]: mutable references are not allowed in statics
   --> $DIR/E0388.rs:5:39
    |
 LL | static STATIC_REF: &'static mut i32 = &mut X;
-   |                                       ^^^^^^ statics require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                                       ^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0596]: cannot borrow immutable static item `X` as mutable
   --> $DIR/E0388.rs:5:39
@@ -30,16 +24,13 @@ error[E0596]: cannot borrow immutable static item `X` as mutable
 LL | static STATIC_REF: &'static mut i32 = &mut X;
    |                                       ^^^^^^ cannot borrow as mutable
 
-error[E0658]: references in statics may only refer to immutable values
+error[E0019]: mutable references are not allowed in statics
   --> $DIR/E0388.rs:8:38
    |
 LL | static CONST_REF: &'static mut i32 = &mut C;
-   |                                      ^^^^^^ statics require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                                      ^^^^^^ `&mut` is only allowed in `const fn`
 
 error: aborting due to 5 previous errors
 
-Some errors have detailed explanations: E0019, E0596, E0658.
+Some errors have detailed explanations: E0019, E0596.
 For more information about an error, try `rustc --explain E0019`.
diff --git a/src/test/ui/issues/issue-17718-const-bad-values.rs b/src/test/ui/issues/issue-17718-const-bad-values.rs
index 9355c8ab152..49023f18ddb 100644
--- a/src/test/ui/issues/issue-17718-const-bad-values.rs
+++ b/src/test/ui/issues/issue-17718-const-bad-values.rs
@@ -1,10 +1,10 @@
 const C1: &'static mut [usize] = &mut [];
-//~^ ERROR: references in constants may only refer to immutable values
+//~^ ERROR: mutable references are not allowed in constants
 
 static mut S: usize = 3;
 const C2: &'static mut usize = unsafe { &mut S };
 //~^ ERROR: constants cannot refer to statics
 //~| ERROR: constants cannot refer to statics
-//~| ERROR: references in constants may only refer to immutable values
+//~| ERROR: mutable references are not allowed in constants
 
 fn main() {}
diff --git a/src/test/ui/issues/issue-17718-const-bad-values.stderr b/src/test/ui/issues/issue-17718-const-bad-values.stderr
index 688efcdd022..b62adbd8493 100644
--- a/src/test/ui/issues/issue-17718-const-bad-values.stderr
+++ b/src/test/ui/issues/issue-17718-const-bad-values.stderr
@@ -1,11 +1,8 @@
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/issue-17718-const-bad-values.rs:1:34
    |
 LL | const C1: &'static mut [usize] = &mut [];
-   |                                  ^^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                                  ^^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0013]: constants cannot refer to statics
   --> $DIR/issue-17718-const-bad-values.rs:5:46
@@ -23,16 +20,13 @@ LL | const C2: &'static mut usize = unsafe { &mut S };
    |
    = help: consider extracting the value of the `static` to a `const`, and referring to that
 
-error[E0658]: references in constants may only refer to immutable values
+error[E0019]: mutable references are not allowed in constants
   --> $DIR/issue-17718-const-bad-values.rs:5:41
    |
 LL | const C2: &'static mut usize = unsafe { &mut S };
-   |                                         ^^^^^^ constants require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                                         ^^^^^^ `&mut` is only allowed in `const fn`
 
 error: aborting due to 4 previous errors
 
-Some errors have detailed explanations: E0013, E0658.
+Some errors have detailed explanations: E0013, E0019.
 For more information about an error, try `rustc --explain E0013`.
diff --git a/src/test/ui/issues/issue-46604.rs b/src/test/ui/issues/issue-46604.rs
index e1967eb7655..3eba1bb20bd 100644
--- a/src/test/ui/issues/issue-46604.rs
+++ b/src/test/ui/issues/issue-46604.rs
@@ -1,4 +1,4 @@
-static buf: &mut [u8] = &mut [1u8,2,3,4,5,7];   //~ ERROR E0658
+static buf: &mut [u8] = &mut [1u8,2,3,4,5,7];   //~ ERROR E0019
 fn write<T: AsRef<[u8]>>(buffer: T) { }
 
 fn main() {
diff --git a/src/test/ui/issues/issue-46604.stderr b/src/test/ui/issues/issue-46604.stderr
index 771e368a35d..b0acf9936c5 100644
--- a/src/test/ui/issues/issue-46604.stderr
+++ b/src/test/ui/issues/issue-46604.stderr
@@ -1,11 +1,8 @@
-error[E0658]: references in statics may only refer to immutable values
+error[E0019]: mutable references are not allowed in statics
   --> $DIR/issue-46604.rs:1:25
    |
 LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7];
-   |                         ^^^^^^^^^^^^^^^^^^^^ statics require immutable values
-   |
-   = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
-   = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
+   |                         ^^^^^^^^^^^^^^^^^^^^ `&mut` is only allowed in `const fn`
 
 error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item
   --> $DIR/issue-46604.rs:6:5
@@ -15,5 +12,5 @@ LL |     buf[0]=2;
 
 error: aborting due to 2 previous errors
 
-Some errors have detailed explanations: E0594, E0658.
-For more information about an error, try `rustc --explain E0594`.
+Some errors have detailed explanations: E0019, E0594.
+For more information about an error, try `rustc --explain E0019`.