Update miri_unleashed tests

This commit is contained in:
Christian Poveda 2019-11-26 11:00:30 -05:00
parent 683f5c9c23
commit 681690db4e
4 changed files with 6 additions and 53 deletions

View file

@ -12,9 +12,7 @@ const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
const MUTATING_BEHIND_RAW: () = {
// Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
unsafe {
*MUTABLE_BEHIND_RAW = 99 //~ WARN skipping const checks
//~^ ERROR any use of this value will cause an error
//~^^ tried to modify constant memory
*MUTABLE_BEHIND_RAW = 99 //~ ERROR constant contains unimplemented expression type
}
};

View file

@ -4,30 +4,12 @@ warning: skipping const checks
LL | const MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _;
| ^^^^^^^^^^^^^^^^^^^^
warning: skipping const checks
error[E0019]: constant contains unimplemented expression type
--> $DIR/mutable_const.rs:15:9
|
LL | *MUTABLE_BEHIND_RAW = 99
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: any use of this value will cause an error
--> $DIR/mutable_const.rs:15:9
|
LL | / const MUTATING_BEHIND_RAW: () = {
LL | | // Test that `MUTABLE_BEHIND_RAW` is actually immutable, by doing this at const time.
LL | | unsafe {
LL | | *MUTABLE_BEHIND_RAW = 99
| | ^^^^^^^^^^^^^^^^^^^^^^^^ tried to modify constant memory
... |
LL | | }
LL | | };
| |__-
|
note: lint level defined here
--> $DIR/mutable_const.rs:4:9
|
LL | #![deny(const_err)]
| ^^^^^^^^^
error: aborting due to previous error
For more information about this error, try `rustc --explain E0019`.

View file

@ -1,4 +1,5 @@
// compile-flags: -Zunleash-the-miri-inside-of-you
#![feature(const_mut_refs)]
#![allow(const_err)]
use std::cell::UnsafeCell;
@ -6,15 +7,12 @@ use std::cell::UnsafeCell;
// a test demonstrating what things we could allow with a smarter const qualification
static FOO: &&mut u32 = &&mut 42;
//~^ WARN: skipping const checks
static BAR: &mut () = &mut ();
//~^ WARN: skipping const checks
struct Foo<T>(T);
static BOO: &mut Foo<()> = &mut Foo(());
//~^ WARN: skipping const checks
struct Meh {
x: &'static UnsafeCell<i32>,
@ -28,7 +26,6 @@ static MEH: Meh = Meh {
};
static OH_YES: &mut i32 = &mut 42;
//~^ WARN: skipping const checks
fn main() {
unsafe {

View file

@ -1,35 +1,11 @@
warning: skipping const checks
--> $DIR/mutable_references.rs:8:26
|
LL | static FOO: &&mut u32 = &&mut 42;
| ^^^^^^^
warning: skipping const checks
--> $DIR/mutable_references.rs:11:23
|
LL | static BAR: &mut () = &mut ();
| ^^^^^^^
warning: skipping const checks
--> $DIR/mutable_references.rs:16:28
|
LL | static BOO: &mut Foo<()> = &mut Foo(());
| ^^^^^^^^^^^^
warning: skipping const checks
--> $DIR/mutable_references.rs:26:8
--> $DIR/mutable_references.rs:24:8
|
LL | x: &UnsafeCell::new(42),
| ^^^^^^^^^^^^^^^^^^^^
warning: skipping const checks
--> $DIR/mutable_references.rs:30:27
|
LL | static OH_YES: &mut i32 = &mut 42;
| ^^^^^^^
error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item
--> $DIR/mutable_references.rs:37:5
--> $DIR/mutable_references.rs:34:5
|
LL | *OH_YES = 99;
| ^^^^^^^^^^^^ cannot assign