mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-17 01:13:11 +00:00
update tests
This commit is contained in:
parent
2f9d33830c
commit
014e605870
@ -1,5 +1,3 @@
|
||||
// check-pass
|
||||
|
||||
#![feature(const_mut_refs)]
|
||||
#![feature(const_fn)]
|
||||
#![feature(raw_ref_op)]
|
||||
@ -24,7 +22,9 @@ const fn baz(foo: &mut Foo)-> *mut usize {
|
||||
|
||||
const _: () = {
|
||||
foo().bar();
|
||||
//~^ ERROR references in constants may only refer to immutable values
|
||||
baz(&mut foo());
|
||||
//~^ ERROR references in constants may only refer to immutable values
|
||||
};
|
||||
|
||||
fn main() {}
|
||||
|
@ -0,0 +1,21 @@
|
||||
error[E0658]: references in constants may only refer to immutable values
|
||||
--> $DIR/const_mut_address_of.rs:24:5
|
||||
|
|
||||
LL | foo().bar();
|
||||
| ^^^^^ constants require immutable values
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: references in constants may only refer to immutable values
|
||||
--> $DIR/const_mut_address_of.rs:26:9
|
||||
|
|
||||
LL | baz(&mut foo());
|
||||
| ^^^^^^^^^^ constants require immutable values
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -1,5 +1,3 @@
|
||||
// run-pass
|
||||
|
||||
#![feature(const_mut_refs)]
|
||||
|
||||
struct Foo {
|
||||
@ -31,6 +29,9 @@ const fn bazz(foo: &mut Foo) -> usize {
|
||||
|
||||
fn main() {
|
||||
let _: [(); foo().bar()] = [(); 1];
|
||||
//~^ ERROR references in constants may only refer to immutable values
|
||||
let _: [(); baz(&mut foo())] = [(); 2];
|
||||
//~^ ERROR references in constants may only refer to immutable values
|
||||
let _: [(); bazz(&mut foo())] = [(); 3];
|
||||
//~^ ERROR references in constants may only refer to immutable values
|
||||
}
|
||||
|
30
src/test/ui/consts/const-mut-refs/const_mut_refs.stderr
Normal file
30
src/test/ui/consts/const-mut-refs/const_mut_refs.stderr
Normal file
@ -0,0 +1,30 @@
|
||||
error[E0658]: references in constants may only refer to immutable values
|
||||
--> $DIR/const_mut_refs.rs:31:17
|
||||
|
|
||||
LL | let _: [(); foo().bar()] = [(); 1];
|
||||
| ^^^^^ constants require immutable values
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: references in constants may only refer to immutable values
|
||||
--> $DIR/const_mut_refs.rs:33:21
|
||||
|
|
||||
LL | let _: [(); baz(&mut foo())] = [(); 2];
|
||||
| ^^^^^^^^^^ constants require immutable values
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: references in constants may only refer to immutable values
|
||||
--> $DIR/const_mut_refs.rs:35:22
|
||||
|
|
||||
LL | let _: [(); bazz(&mut foo())] = [(); 3];
|
||||
| ^^^^^^^^^^ constants require immutable values
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to 3 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
@ -1,3 +1,12 @@
|
||||
error[E0658]: references in constants may only refer to immutable values
|
||||
--> $DIR/projection_qualif.rs:10:27
|
||||
|
|
||||
LL | let b: *mut u32 = &mut a;
|
||||
| ^^^^^^ constants require immutable values
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= help: add `#![feature(const_mut_refs)]` to the crate attributes to enable
|
||||
|
||||
error[E0658]: dereferencing raw pointers in constants is unstable
|
||||
--> $DIR/projection_qualif.rs:11:18
|
||||
|
|
||||
@ -7,6 +16,6 @@ LL | unsafe { *b = 5; }
|
||||
= note: see issue #51911 <https://github.com/rust-lang/rust/issues/51911> for more information
|
||||
= help: add `#![feature(const_raw_ptr_deref)]` to the crate attributes to enable
|
||||
|
||||
error: aborting due to previous error
|
||||
error: aborting due to 2 previous errors
|
||||
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
@ -7,7 +7,7 @@ use std::cell::Cell;
|
||||
const FOO: &u32 = {
|
||||
let mut a = 42;
|
||||
{
|
||||
let b: *mut u32 = &mut a; //[stock]~ ERROR may only refer to immutable values
|
||||
let b: *mut u32 = &mut a; //~ ERROR may only refer to immutable values
|
||||
unsafe { *b = 5; } //~ ERROR dereferencing raw pointers in constants
|
||||
//[stock]~^ contains unimplemented expression
|
||||
}
|
||||
|
@ -1,10 +1,8 @@
|
||||
// run-pass
|
||||
#![feature(const_mut_refs)]
|
||||
#![allow(const_err)]
|
||||
|
||||
static OH_YES: &mut i32 = &mut 42;
|
||||
|
||||
static OH_NO: &mut i32 = &mut 42;
|
||||
//~^ ERROR references in statics may only refer to immutable values
|
||||
fn main() {
|
||||
// Make sure `OH_YES` can be read.
|
||||
assert_eq!(*OH_YES, 42);
|
||||
assert_eq!(*OH_NO, 42);
|
||||
}
|
||||
|
12
src/test/ui/consts/read_from_static_mut_ref.stderr
Normal file
12
src/test/ui/consts/read_from_static_mut_ref.stderr
Normal file
@ -0,0 +1,12 @@
|
||||
error[E0658]: references in statics may only refer to immutable values
|
||||
--> $DIR/read_from_static_mut_ref.rs:4:26
|
||||
|
|
||||
LL | static OH_NO: &mut i32 = &mut 42;
|
||||
| ^^^^^^^ statics require immutable values
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= 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 E0658`.
|
@ -1,9 +1,12 @@
|
||||
error[E0080]: could not evaluate static initializer
|
||||
--> $DIR/static_mut_containing_mut_ref2.rs:7:45
|
||||
error[E0658]: references in statics may only refer to immutable values
|
||||
--> $DIR/static_mut_containing_mut_ref2.rs:7:46
|
||||
|
|
||||
LL | pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ modifying a static's initial value from another static's initializer
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ statics require immutable values
|
||||
|
|
||||
= note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information
|
||||
= 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 E0080`.
|
||||
For more information about this error, try `rustc --explain E0658`.
|
||||
|
@ -5,8 +5,7 @@
|
||||
static mut STDERR_BUFFER_SPACE: u8 = 0;
|
||||
|
||||
pub static mut STDERR_BUFFER: () = unsafe { *(&mut STDERR_BUFFER_SPACE) = 42; };
|
||||
//[mut_refs]~^ ERROR could not evaluate static initializer
|
||||
//[stock]~^^ ERROR references in statics may only refer to immutable values
|
||||
//~^ ERROR references in statics may only refer to immutable values
|
||||
//[stock]~| ERROR static contains unimplemented expression type
|
||||
|
||||
fn main() {}
|
||||
|
Loading…
Reference in New Issue
Block a user