Skip to content

Commit

Permalink
Correct other tests related to const_mut_refs
Browse files Browse the repository at this point in the history
  • Loading branch information
pvdrz committed Dec 2, 2019
1 parent dc0117a commit 416b439
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/test/compile-fail/consts/const-fn-error.rs
Expand Up @@ -6,7 +6,7 @@ const fn f(x: usize) -> usize {
let mut sum = 0;
for i in 0..x {
//~^ ERROR E0015
//~| ERROR E0017
//~| ERROR E0658
//~| ERROR E0080
//~| ERROR E0744
//~| ERROR E0019
Expand Down
7 changes: 5 additions & 2 deletions src/test/ui/check-static-immutable-mut-slices.stderr
@@ -1,9 +1,12 @@
error[E0017]: references in statics may only refer to immutable values
error[E0658]: references in statics may only refer to immutable values
--> $DIR/check-static-immutable-mut-slices.rs:3:37
|
LL | static TEST: &'static mut [isize] = &mut [];
| ^^^^^^^ statics require immutable values
|
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error: aborting due to previous error

For more information about this error, try `rustc --explain E0017`.
For more information about this error, try `rustc --explain E0658`.
8 changes: 4 additions & 4 deletions src/test/ui/error-codes/E0017.rs
Expand Up @@ -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 E0017
static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
const CR: &'static mut i32 = &mut C; //~ ERROR E0658
static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0658
//~| ERROR E0019
//~| ERROR cannot borrow
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; //~ ERROR E0017
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0658
static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; //~ ERROR E0658
fn main() {}
24 changes: 18 additions & 6 deletions src/test/ui/error-codes/E0017.stderr
@@ -1,40 +1,52 @@
error[E0017]: references in constants may only refer to immutable values
error[E0658]: references in constants may only refer to immutable values
--> $DIR/E0017.rs:5:30
|
LL | const CR: &'static mut i32 = &mut C;
| ^^^^^^ constants require immutable values
|
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error[E0019]: static contains unimplemented expression type
--> $DIR/E0017.rs:6:39
|
LL | static STATIC_REF: &'static mut i32 = &mut X;
| ^^^^^^

error[E0017]: references in statics may only refer to immutable values
error[E0658]: references in statics may only refer to immutable values
--> $DIR/E0017.rs:6:39
|
LL | static STATIC_REF: &'static mut i32 = &mut X;
| ^^^^^^ statics require immutable values
|
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error[E0596]: cannot borrow immutable static item `X` as mutable
--> $DIR/E0017.rs:6:39
|
LL | static STATIC_REF: &'static mut i32 = &mut X;
| ^^^^^^ cannot borrow as mutable

error[E0017]: references in statics may only refer to immutable values
error[E0658]: references in statics may only refer to immutable values
--> $DIR/E0017.rs:9:38
|
LL | static CONST_REF: &'static mut i32 = &mut C;
| ^^^^^^ statics require immutable values
|
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error[E0017]: references in statics may only refer to immutable values
error[E0658]: references in statics may only refer to immutable values
--> $DIR/E0017.rs:10:52
|
LL | static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M };
| ^^^^^^ statics require immutable values
|
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error: aborting due to 6 previous errors

Some errors have detailed explanations: E0017, E0019, E0596.
For more information about an error, try `rustc --explain E0017`.
Some errors have detailed explanations: E0019, E0596, E0658.
For more information about an error, try `rustc --explain E0019`.
10 changes: 10 additions & 0 deletions src/test/ui/error-codes/E0388.rs
@@ -0,0 +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
//~| ERROR cannot borrow
//~| ERROR E0019
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0658

fn main() {}
43 changes: 43 additions & 0 deletions src/test/ui/error-codes/E0388.stderr
@@ -0,0 +1,43 @@
error[E0658]: references in constants may only refer to immutable values
--> $DIR/E0388.rs:4:30
|
LL | const CR: &'static mut i32 = &mut C;
| ^^^^^^ constants require immutable values
|
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error[E0019]: static contains unimplemented expression type
--> $DIR/E0388.rs:5:39
|
LL | static STATIC_REF: &'static mut i32 = &mut X;
| ^^^^^^

error[E0658]: references in statics may only refer to immutable values
--> $DIR/E0388.rs:5:39
|
LL | static STATIC_REF: &'static mut i32 = &mut X;
| ^^^^^^ statics require immutable values
|
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error[E0596]: cannot borrow immutable static item `X` as mutable
--> $DIR/E0388.rs:5:39
|
LL | static STATIC_REF: &'static mut i32 = &mut X;
| ^^^^^^ cannot borrow as mutable

error[E0658]: references in statics may only refer to immutable values
--> $DIR/E0388.rs:8:38
|
LL | static CONST_REF: &'static mut i32 = &mut C;
| ^^^^^^ statics require immutable values
|
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error: aborting due to 5 previous errors

Some errors have detailed explanations: E0019, E0596, E0658.
For more information about an error, try `rustc --explain E0019`.
12 changes: 9 additions & 3 deletions src/test/ui/issues/issue-17718-const-bad-values.stderr
@@ -1,22 +1,28 @@
error[E0017]: references in constants may only refer to immutable values
error[E0658]: references in constants may only refer to immutable values
--> $DIR/issue-17718-const-bad-values.rs:1:34
|
LL | const C1: &'static mut [usize] = &mut [];
| ^^^^^^^ constants require immutable values
|
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error[E0013]: constants cannot refer to statics, use a constant instead
--> $DIR/issue-17718-const-bad-values.rs:5:46
|
LL | const C2: &'static mut usize = unsafe { &mut S };
| ^

error[E0017]: references in constants may only refer to immutable values
error[E0658]: references in constants may only refer to immutable values
--> $DIR/issue-17718-const-bad-values.rs:5:41
|
LL | const C2: &'static mut usize = unsafe { &mut S };
| ^^^^^^ constants require immutable values
|
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error: aborting due to 3 previous errors

Some errors have detailed explanations: E0013, E0017.
Some errors have detailed explanations: E0013, E0658.
For more information about an error, try `rustc --explain E0013`.
2 changes: 1 addition & 1 deletion src/test/ui/issues/issue-46604.rs
@@ -1,4 +1,4 @@
static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //~ ERROR E0017
static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //~ ERROR E0658
fn write<T: AsRef<[u8]>>(buffer: T) { }

fn main() {
Expand Down
9 changes: 6 additions & 3 deletions src/test/ui/issues/issue-46604.stderr
@@ -1,8 +1,11 @@
error[E0017]: references in statics may only refer to immutable values
error[E0658]: references in statics may only refer to immutable values
--> $DIR/issue-46604.rs:1:25
|
LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7];
| ^^^^^^^^^^^^^^^^^^^^ statics require immutable values
|
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable

error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item
--> $DIR/issue-46604.rs:6:5
Expand All @@ -12,5 +15,5 @@ LL | buf[0]=2;

error: aborting due to 2 previous errors

Some errors have detailed explanations: E0017, E0594.
For more information about an error, try `rustc --explain E0017`.
Some errors have detailed explanations: E0594, E0658.
For more information about an error, try `rustc --explain E0594`.

0 comments on commit 416b439

Please sign in to comment.