Skip to content

Commit 4fde337

Browse files
committed
examples straight from hell
1 parent a2352fe commit 4fde337

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

tests/ui/consts/miri_unleashed/mutable_references_err.rs

+2
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF };
5454
//~^ ERROR: evaluation of constant value failed
5555
//~| accesses static
5656

57+
const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _;
58+
5759
fn main() {
5860
unsafe {
5961
*MUH.x.get() = 99;

tests/ui/consts/miri_unleashed/static-no-inner-mut.rs

+4-3
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; //~ERROR undefined behavio
2121
// commented out.)
2222
// static RAW: *const AtomicI32 = &AtomicI32::new(42);
2323

24-
struct SyncPtr<T>(*const T);
24+
struct SyncPtr<T> { x : *const T }
2525
unsafe impl<T> Sync for SyncPtr<T> {}
2626

2727
// This one does not get promoted, and then the reference is simply too short-lived.
28-
static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr(&AtomicI32::new(42)); //~ERROR dangling pointer
29-
static RAW_MUT: SyncPtr<i32> = SyncPtr(&mut 42 as *mut _ as *const _); //~ERROR dangling pointer
28+
static RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) };
29+
static RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ };
30+
static RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 };
3031

3132
fn main() {}

0 commit comments

Comments
 (0)