File tree 10 files changed +90
-17
lines changed
10 files changed +90
-17
lines changed Original file line number Diff line number Diff line change 1
- // check-pass
2
-
3
1
#![ feature( const_mut_refs) ]
4
2
#![ feature( const_fn) ]
5
3
#![ feature( raw_ref_op) ]
@@ -24,7 +22,9 @@ const fn baz(foo: &mut Foo)-> *mut usize {
24
22
25
23
const _: ( ) = {
26
24
foo ( ) . bar ( ) ;
25
+ //~^ ERROR references in constants may only refer to immutable values
27
26
baz ( & mut foo ( ) ) ;
27
+ //~^ ERROR references in constants may only refer to immutable values
28
28
} ;
29
29
30
30
fn main ( ) { }
Original file line number Diff line number Diff line change
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`.
Original file line number Diff line number Diff line change 1
- // run-pass
2
-
3
1
#![ feature( const_mut_refs) ]
4
2
5
3
struct Foo {
@@ -31,6 +29,9 @@ const fn bazz(foo: &mut Foo) -> usize {
31
29
32
30
fn main ( ) {
33
31
let _: [ ( ) ; foo ( ) . bar ( ) ] = [ ( ) ; 1 ] ;
32
+ //~^ ERROR references in constants may only refer to immutable values
34
33
let _: [ ( ) ; baz ( & mut foo ( ) ) ] = [ ( ) ; 2 ] ;
34
+ //~^ ERROR references in constants may only refer to immutable values
35
35
let _: [ ( ) ; bazz ( & mut foo ( ) ) ] = [ ( ) ; 3 ] ;
36
+ //~^ ERROR references in constants may only refer to immutable values
36
37
}
Original file line number Diff line number Diff line change
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`.
Original file line number Diff line number Diff line change
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
+
1
10
error[E0658]: dereferencing raw pointers in constants is unstable
2
11
--> $DIR/projection_qualif.rs:11:18
3
12
|
@@ -7,6 +16,6 @@ LL | unsafe { *b = 5; }
7
16
= note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information
8
17
= help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
9
18
10
- error: aborting due to previous error
19
+ error: aborting due to 2 previous errors
11
20
12
21
For more information about this error, try `rustc --explain E0658`.
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ use std::cell::Cell;
7
7
const FOO : & u32 = {
8
8
let mut a = 42 ;
9
9
{
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
11
11
unsafe { * b = 5 ; } //~ ERROR dereferencing raw pointers in constants
12
12
//[stock]~^ contains unimplemented expression
13
13
}
Original file line number Diff line number Diff line change 1
- // run-pass
2
1
#![ feature( const_mut_refs) ]
3
2
#![ allow( const_err) ]
4
3
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
7
6
fn main ( ) {
8
- // Make sure `OH_YES` can be read.
9
- assert_eq ! ( * OH_YES , 42 ) ;
7
+ assert_eq ! ( * OH_NO , 42 ) ;
10
8
}
Original file line number Diff line number Diff line change
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 number Diff line number Diff line change 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
3
3
|
4
4
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
6
9
7
10
error: aborting due to previous error
8
11
9
- For more information about this error, try `rustc --explain E0080 `.
12
+ For more information about this error, try `rustc --explain E0658 `.
Original file line number Diff line number Diff line change 5
5
static mut STDERR_BUFFER_SPACE : u8 = 0 ;
6
6
7
7
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
10
9
//[stock]~| ERROR static contains unimplemented expression type
11
10
12
11
fn main ( ) { }
You can’t perform that action at this time.
0 commit comments