Skip to content

Commit 014e605

Browse files
committed
update tests
1 parent 2f9d338 commit 014e605

10 files changed

+90
-17
lines changed

src/test/ui/consts/const-mut-refs/const_mut_address_of.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// check-pass
2-
31
#![feature(const_mut_refs)]
42
#![feature(const_fn)]
53
#![feature(raw_ref_op)]
@@ -24,7 +22,9 @@ const fn baz(foo: &mut Foo)-> *mut usize {
2422

2523
const _: () = {
2624
foo().bar();
25+
//~^ ERROR references in constants may only refer to immutable values
2726
baz(&mut foo());
27+
//~^ ERROR references in constants may only refer to immutable values
2828
};
2929

3030
fn main() {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
error[E0658]: references in constants may only refer to immutable values
2+
--> $DIR/const_mut_address_of.rs:24:5
3+
|
4+
LL | foo().bar();
5+
| ^^^^^ constants require immutable values
6+
|
7+
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
8+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
9+
10+
error[E0658]: references in constants may only refer to immutable values
11+
--> $DIR/const_mut_address_of.rs:26:9
12+
|
13+
LL | baz(&mut foo());
14+
| ^^^^^^^^^^ constants require immutable values
15+
|
16+
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
17+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
18+
19+
error: aborting due to 2 previous errors
20+
21+
For more information about this error, try `rustc --explain E0658`.

src/test/ui/consts/const-mut-refs/const_mut_refs.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// run-pass
2-
31
#![feature(const_mut_refs)]
42

53
struct Foo {
@@ -31,6 +29,9 @@ const fn bazz(foo: &mut Foo) -> usize {
3129

3230
fn main() {
3331
let _: [(); foo().bar()] = [(); 1];
32+
//~^ ERROR references in constants may only refer to immutable values
3433
let _: [(); baz(&mut foo())] = [(); 2];
34+
//~^ ERROR references in constants may only refer to immutable values
3535
let _: [(); bazz(&mut foo())] = [(); 3];
36+
//~^ ERROR references in constants may only refer to immutable values
3637
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
error[E0658]: references in constants may only refer to immutable values
2+
--> $DIR/const_mut_refs.rs:31:17
3+
|
4+
LL | let _: [(); foo().bar()] = [(); 1];
5+
| ^^^^^ constants require immutable values
6+
|
7+
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
8+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
9+
10+
error[E0658]: references in constants may only refer to immutable values
11+
--> $DIR/const_mut_refs.rs:33:21
12+
|
13+
LL | let _: [(); baz(&mut foo())] = [(); 2];
14+
| ^^^^^^^^^^ constants require immutable values
15+
|
16+
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
17+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
18+
19+
error[E0658]: references in constants may only refer to immutable values
20+
--> $DIR/const_mut_refs.rs:35:22
21+
|
22+
LL | let _: [(); bazz(&mut foo())] = [(); 3];
23+
| ^^^^^^^^^^ constants require immutable values
24+
|
25+
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
26+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
27+
28+
error: aborting due to 3 previous errors
29+
30+
For more information about this error, try `rustc --explain E0658`.

src/test/ui/consts/projection_qualif.mut_refs.stderr

+10-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
1+
error[E0658]: references in constants may only refer to immutable values
2+
--> $DIR/projection_qualif.rs:10:27
3+
|
4+
LL | let b: *mut u32 = &mut a;
5+
| ^^^^^^ constants require immutable values
6+
|
7+
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
8+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
9+
110
error[E0658]: dereferencing raw pointers in constants is unstable
211
--> $DIR/projection_qualif.rs:11:18
312
|
@@ -7,6 +16,6 @@ LL | unsafe { *b = 5; }
716
= note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information
817
= help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
918

10-
error: aborting due to previous error
19+
error: aborting due to 2 previous errors
1120

1221
For more information about this error, try `rustc --explain E0658`.

src/test/ui/consts/projection_qualif.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::cell::Cell;
77
const FOO: &u32 = {
88
let mut a = 42;
99
{
10-
let b: *mut u32 = &mut a; //[stock]~ ERROR may only refer to immutable values
10+
let b: *mut u32 = &mut a; //~ ERROR may only refer to immutable values
1111
unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants
1212
//[stock]~^ contains unimplemented expression
1313
}
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
1-
// run-pass
21
#![feature(const_mut_refs)]
32
#![allow(const_err)]
43

5-
static OH_YES: &mut i32 = &mut 42;
6-
4+
static OH_NO: &mut i32 = &mut 42;
5+
//~^ ERROR references in statics may only refer to immutable values
76
fn main() {
8-
// Make sure `OH_YES` can be read.
9-
assert_eq!(*OH_YES, 42);
7+
assert_eq!(*OH_NO, 42);
108
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
error[E0658]: references in statics may only refer to immutable values
2+
--> $DIR/read_from_static_mut_ref.rs:4:26
3+
|
4+
LL | static OH_NO: &mut i32 = &mut 42;
5+
| ^^^^^^^ statics require immutable values
6+
|
7+
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
8+
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
9+
10+
error: aborting due to previous error
11+
12+
For more information about this error, try `rustc --explain E0658`.
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
1-
error[E0080]: could not evaluate static initializer
2-
--> $DIR/static_mut_containing_mut_ref2.rs:7:45
1+
error[E0658]: references in statics may only refer to immutable values
2+
--> $DIR/static_mut_containing_mut_ref2.rs:7:46
33
|
44
LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
5-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ statics require immutable values
6+
|
7+
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
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 E0080`.
12+
For more information about this error, try `rustc --explain E0658`.

src/test/ui/consts/static_mut_containing_mut_ref2.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
static mut STDERR_BUFFER_SPACE: u8 = 0;
66

77
pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
8-
//[mut_refs]~^ ERROR could not evaluate static initializer
9-
//[stock]~^^ ERROR references in statics may only refer to immutable values
8+
//~^ ERROR references in statics may only refer to immutable values
109
//[stock]~| ERROR static contains unimplemented expression type
1110

1211
fn main() {}

0 commit comments

Comments
 (0)