Correct other tests related to const_mut_refs

This commit is contained in:
Christian Poveda 2019-11-28 12:20:28 -05:00
parent dc0117a42c
commit 416b439ffb
9 changed files with 97 additions and 20 deletions

View file

@ -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

View file

@ -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`.

View file

@ -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() {}

View file

@ -1,8 +1,11 @@
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
@ -10,11 +13,14 @@ error[E0019]: static contains unimplemented expression type
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
@ -22,19 +28,25 @@ error[E0596]: cannot borrow immutable static item `X` as mutable
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`.

View file

@ -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() {}

View file

@ -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`.

View file

@ -1,8 +1,11 @@
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
@ -10,13 +13,16 @@ error[E0013]: constants cannot refer to statics, use a constant instead
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`.

View file

@ -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() {

View file

@ -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
@ -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`.