Skip to content

Commit 416b439

Browse files
committed
Correct other tests related to const_mut_refs
1 parent dc0117a commit 416b439

9 files changed

+97
-20
lines changed

src/test/compile-fail/consts/const-fn-error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const fn f(x: usize) -> usize {
66
let mut sum = 0;
77
for i in 0..x {
88
//~^ ERROR E0015
9-
//~| ERROR E0017
9+
//~| ERROR E0658
1010
//~| ERROR E0080
1111
//~| ERROR E0744
1212
//~| ERROR E0019
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
error[E0017]: references in statics may only refer to immutable values
1+
error[E0658]: references in statics may only refer to immutable values
22
--> $DIR/check-static-immutable-mut-slices.rs:3:37
33
|
44
LL | static TEST: &'static mut [isize] = &mut [];
55
| ^^^^^^^ statics require immutable values
6+
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
8+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
69

710
error: aborting due to previous error
811

9-
For more information about this error, try `rustc --explain E0017`.
12+
For more information about this error, try `rustc --explain E0658`.

src/test/ui/error-codes/E0017.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@ static X: i32 = 1;
22
const C: i32 = 2;
33
static mut M: i32 = 3;
44

5-
const CR: &'static mut i32 = &mut C; //~ ERROR E0017
6-
static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0017
5+
const CR: &'static mut i32 = &mut C; //~ ERROR E0658
6+
static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0658
77
//~| ERROR E0019
88
//~| ERROR cannot borrow
9-
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0017
10-
static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; //~ ERROR E0017
9+
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0658
10+
static STATIC_MUT_REF: &'static mut i32 = unsafe { &mut M }; //~ ERROR E0658
1111
fn main() {}

src/test/ui/error-codes/E0017.stderr

+18-6
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,52 @@
1-
error[E0017]: references in constants may only refer to immutable values
1+
error[E0658]: references in constants may only refer to immutable values
22
--> $DIR/E0017.rs:5:30
33
|
44
LL | const CR: &'static mut i32 = &mut C;
55
| ^^^^^^ constants require immutable values
6+
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
8+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
69

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

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

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

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

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

3749
error: aborting due to 6 previous errors
3850

39-
Some errors have detailed explanations: E0017, E0019, E0596.
40-
For more information about an error, try `rustc --explain E0017`.
51+
Some errors have detailed explanations: E0019, E0596, E0658.
52+
For more information about an error, try `rustc --explain E0019`.

src/test/ui/error-codes/E0388.rs

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
static X: i32 = 1;
2+
const C: i32 = 2;
3+
4+
const CR: &'static mut i32 = &mut C; //~ ERROR E0658
5+
static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR E0658
6+
//~| ERROR cannot borrow
7+
//~| ERROR E0019
8+
static CONST_REF: &'static mut i32 = &mut C; //~ ERROR E0658
9+
10+
fn main() {}

src/test/ui/error-codes/E0388.stderr

+43
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
error[E0658]: references in constants may only refer to immutable values
2+
--> $DIR/E0388.rs:4:30
3+
|
4+
LL | const CR: &'static mut i32 = &mut C;
5+
| ^^^^^^ constants require immutable values
6+
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
8+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
9+
10+
error[E0019]: static contains unimplemented expression type
11+
--> $DIR/E0388.rs:5:39
12+
|
13+
LL | static STATIC_REF: &'static mut i32 = &mut X;
14+
| ^^^^^^
15+
16+
error[E0658]: references in statics may only refer to immutable values
17+
--> $DIR/E0388.rs:5:39
18+
|
19+
LL | static STATIC_REF: &'static mut i32 = &mut X;
20+
| ^^^^^^ statics require immutable values
21+
|
22+
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
23+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
24+
25+
error[E0596]: cannot borrow immutable static item `X` as mutable
26+
--> $DIR/E0388.rs:5:39
27+
|
28+
LL | static STATIC_REF: &'static mut i32 = &mut X;
29+
| ^^^^^^ cannot borrow as mutable
30+
31+
error[E0658]: references in statics may only refer to immutable values
32+
--> $DIR/E0388.rs:8:38
33+
|
34+
LL | static CONST_REF: &'static mut i32 = &mut C;
35+
| ^^^^^^ statics require immutable values
36+
|
37+
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
38+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
39+
40+
error: aborting due to 5 previous errors
41+
42+
Some errors have detailed explanations: E0019, E0596, E0658.
43+
For more information about an error, try `rustc --explain E0019`.
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,28 @@
1-
error[E0017]: references in constants may only refer to immutable values
1+
error[E0658]: references in constants may only refer to immutable values
22
--> $DIR/issue-17718-const-bad-values.rs:1:34
33
|
44
LL | const C1: &'static mut [usize] = &mut [];
55
| ^^^^^^^ constants require immutable values
6+
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
8+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
69

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

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

1925
error: aborting due to 3 previous errors
2026

21-
Some errors have detailed explanations: E0013, E0017.
27+
Some errors have detailed explanations: E0013, E0658.
2228
For more information about an error, try `rustc --explain E0013`.

src/test/ui/issues/issue-46604.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //~ ERROR E0017
1+
static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //~ ERROR E0658
22
fn write<T: AsRef<[u8]>>(buffer: T) { }
33

44
fn main() {

src/test/ui/issues/issue-46604.stderr

+6-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
error[E0017]: references in statics may only refer to immutable values
1+
error[E0658]: references in statics may only refer to immutable values
22
--> $DIR/issue-46604.rs:1:25
33
|
44
LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7];
55
| ^^^^^^^^^^^^^^^^^^^^ statics require immutable values
6+
|
7+
= note: for more information, see https://github.com/rust-lang/rust/issues/57349
8+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
69

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

1316
error: aborting due to 2 previous errors
1417

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

0 commit comments

Comments
 (0)