about summary refs log tree commit diff
path: root/src/test/ui/error-codes
diff options
context:
space:
mode:
authoroli <github35764891676564198441@oli-obk.de>2021-01-03 18:46:20 +0000
committeroli <github35764891676564198441@oli-obk.de>2021-01-23 11:33:45 +0000
commitd118021f8bfbfda2cd93277c15c607b2c66ff93c (patch)
tree3bb47effb0df11fc428390a0bbdd7aace551b012 /src/test/ui/error-codes
parent1986b58c646a9523d0a8a0fa8a0bd20492e7795d (diff)
downloadrust-d118021f8bfbfda2cd93277c15c607b2c66ff93c.tar.gz
rust-d118021f8bfbfda2cd93277c15c607b2c66ff93c.zip
Permit mutable references in all const contexts
Diffstat (limited to 'src/test/ui/error-codes')
-rw-r--r--src/test/ui/error-codes/E0017.rs9
-rw-r--r--src/test/ui/error-codes/E0017.stderr35
-rw-r--r--src/test/ui/error-codes/E0388.rs7
-rw-r--r--src/test/ui/error-codes/E0388.stderr29
4 files changed, 50 insertions, 30 deletions
diff --git a/src/test/ui/error-codes/E0017.rs b/src/test/ui/error-codes/E0017.rs
index 262f7bc72c7..c211ad1a2f8 100644
--- a/src/test/ui/error-codes/E0017.rs
+++ b/src/test/ui/error-codes/E0017.rs
@@ -2,12 +2,13 @@ static X: i32 = 1;
 const C: i32 = 2;
 static mut M: i32 = 3;
 
-const CR: &'static mut i32 = &mut C; //~ ERROR E0764
+const CR: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed
                                      //~| WARN taking a mutable
-static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0764
+static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0658
                                               //~| ERROR cannot borrow
+                                              //~| ERROR mutable references are not allowed
 
-static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0764
+static CONST_REF: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed
                                               //~| WARN taking a mutable
-static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; //~ ERROR E0764
+static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; //~ ERROR mutable references are not
 fn main() {}
diff --git a/src/test/ui/error-codes/E0017.stderr b/src/test/ui/error-codes/E0017.stderr
index ea591587e6d..9b094b19757 100644
--- a/src/test/ui/error-codes/E0017.stderr
+++ b/src/test/ui/error-codes/E0017.stderr
@@ -13,17 +13,26 @@ note: `const` item defined here
 LL | const C: i32 = 2;
    | ^^^^^^^^^^^^^^^^^
 
-error[E0764]: mutable references are not allowed in constants
+error[E0764]: mutable references are not allowed in final value of constants
   --> $DIR/E0017.rs:5:30
    |
 LL | const CR: &'static mut i32 = &mut C;
-   |                              ^^^^^^ `&mut` is only allowed in `const fn`
+   |                              ^^^^^^
 
-error[E0764]: mutable references are not allowed in statics
+error[E0658]: mutation through a reference is not allowed in statics
   --> $DIR/E0017.rs:7:39
    |
 LL | static STATIC_REF: &'static mut i32 = &mut X;
-   |                                       ^^^^^^ `&mut` is only allowed in `const fn`
+   |                                       ^^^^^^
+   |
+   = 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
+
+error[E0764]: mutable references are not allowed in final value of statics
+  --> $DIR/E0017.rs:7:39
+   |
+LL | static STATIC_REF: &'static mut i32 = &mut X;
+   |                                       ^^^^^^
 
 error[E0596]: cannot borrow immutable static item `X` as mutable
   --> $DIR/E0017.rs:7:39
@@ -32,7 +41,7 @@ LL | static STATIC_REF: &'static mut i32 = &mut X;
    |                                       ^^^^^^ cannot borrow as mutable
 
 warning: taking a mutable reference to a `const` item
-  --> $DIR/E0017.rs:10:38
+  --> $DIR/E0017.rs:11:38
    |
 LL | static CONST_REF: &'static mut i32 = &mut C;
    |                                      ^^^^^^
@@ -45,19 +54,19 @@ note: `const` item defined here
 LL | const C: i32 = 2;
    | ^^^^^^^^^^^^^^^^^
 
-error[E0764]: mutable references are not allowed in statics
-  --> $DIR/E0017.rs:10:38
+error[E0764]: mutable references are not allowed in final value of statics
+  --> $DIR/E0017.rs:11:38
    |
 LL | static CONST_REF: &'static mut i32 = &mut C;
-   |                                      ^^^^^^ `&mut` is only allowed in `const fn`
+   |                                      ^^^^^^
 
-error[E0764]: mutable references are not allowed in statics
-  --> $DIR/E0017.rs:12:52
+error[E0764]: mutable references are not allowed in final value of statics
+  --> $DIR/E0017.rs:13:52
    |
 LL | static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M };
-   |                                                    ^^^^^^ `&mut` is only allowed in `const fn`
+   |                                                    ^^^^^^
 
-error: aborting due to 5 previous errors; 2 warnings emitted
+error: aborting due to 6 previous errors; 2 warnings emitted
 
-Some errors have detailed explanations: E0596, E0764.
+Some errors have detailed explanations: E0596, E0658, E0764.
 For more information about an error, try `rustc --explain E0596`.
diff --git a/src/test/ui/error-codes/E0388.rs b/src/test/ui/error-codes/E0388.rs
index bb0c4979b9a..6049d95f0d2 100644
--- a/src/test/ui/error-codes/E0388.rs
+++ b/src/test/ui/error-codes/E0388.rs
@@ -1,12 +1,13 @@
 static X: i32 = 1;
 const C: i32 = 2;
 
-const CR: &'static mut i32 = &mut C; //~ ERROR E0764
+const CR: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed
                                      //~| WARN taking a mutable
 static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR cannot borrow
-                                              //~| ERROR E0764
+                                              //~| ERROR E0658
+                                              //~| ERROR mutable references are not allowed
 
-static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0764
+static CONST_REF: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed
                                              //~| WARN taking a mutable
 
 fn main() {}
diff --git a/src/test/ui/error-codes/E0388.stderr b/src/test/ui/error-codes/E0388.stderr
index 73e0b139cd0..74d6a92e170 100644
--- a/src/test/ui/error-codes/E0388.stderr
+++ b/src/test/ui/error-codes/E0388.stderr
@@ -13,17 +13,26 @@ note: `const` item defined here
 LL | const C: i32 = 2;
    | ^^^^^^^^^^^^^^^^^
 
-error[E0764]: mutable references are not allowed in constants
+error[E0764]: mutable references are not allowed in final value of constants
   --> $DIR/E0388.rs:4:30
    |
 LL | const CR: &'static mut i32 = &mut C;
-   |                              ^^^^^^ `&mut` is only allowed in `const fn`
+   |                              ^^^^^^
 
-error[E0764]: mutable references are not allowed in statics
+error[E0658]: mutation through a reference is not allowed in statics
   --> $DIR/E0388.rs:6:39
    |
 LL | static STATIC_REF: &'static mut i32 = &mut X;
-   |                                       ^^^^^^ `&mut` is only allowed in `const fn`
+   |                                       ^^^^^^
+   |
+   = 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
+
+error[E0764]: mutable references are not allowed in final value of statics
+  --> $DIR/E0388.rs:6:39
+   |
+LL | static STATIC_REF: &'static mut i32 = &mut X;
+   |                                       ^^^^^^
 
 error[E0596]: cannot borrow immutable static item `X` as mutable
   --> $DIR/E0388.rs:6:39
@@ -32,7 +41,7 @@ LL | static STATIC_REF: &'static mut i32 = &mut X;
    |                                       ^^^^^^ cannot borrow as mutable
 
 warning: taking a mutable reference to a `const` item
-  --> $DIR/E0388.rs:9:38
+  --> $DIR/E0388.rs:10:38
    |
 LL | static CONST_REF: &'static mut i32 = &mut C;
    |                                      ^^^^^^
@@ -45,13 +54,13 @@ note: `const` item defined here
 LL | const C: i32 = 2;
    | ^^^^^^^^^^^^^^^^^
 
-error[E0764]: mutable references are not allowed in statics
-  --> $DIR/E0388.rs:9:38
+error[E0764]: mutable references are not allowed in final value of statics
+  --> $DIR/E0388.rs:10:38
    |
 LL | static CONST_REF: &'static mut i32 = &mut C;
-   |                                      ^^^^^^ `&mut` is only allowed in `const fn`
+   |                                      ^^^^^^
 
-error: aborting due to 4 previous errors; 2 warnings emitted
+error: aborting due to 5 previous errors; 2 warnings emitted
 
-Some errors have detailed explanations: E0596, E0764.
+Some errors have detailed explanations: E0596, E0658, E0764.
 For more information about an error, try `rustc --explain E0596`.