Skip to content

Commit 6b878ed

Browse files
committed
1 parent bcb87a7 commit 6b878ed

File tree

6 files changed

+8
-12
lines changed

6 files changed

+8
-12
lines changed

rust-version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
0e190206e2ff0c13d64701d9b4145bf89a2d0cab
1+
7ce1b3b24491cbe10669cbe2b5733c2fe7cfe5b7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Make sure we find these even with many checks disabled.
22
// compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation
3-
#![feature(raw_ref_macros)]
43
use std::ptr;
54

65
fn main() {
76
let p = {
87
let b = Box::new(42);
98
&*b as *const i32
109
};
11-
let x = unsafe { ptr::raw_const!(*p) }; //~ ERROR dereferenced after this allocation got freed
10+
let x = unsafe { ptr::addr_of!(*p) }; //~ ERROR dereferenced after this allocation got freed
1211
panic!("this should never print: {:?}", x);
1312
}

tests/compile-fail/extern_static.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
#![feature(raw_ref_op)]
21
//! Even referencing an unknown `extern static` already triggers an error.
32
43
extern "C" {
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// This should fail even without validation or Stacked Borrows.
22
// compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows
3-
#![feature(raw_ref_macros)]
43
use std::ptr;
54

65
fn main() {
@@ -9,6 +8,6 @@ fn main() {
98
let x = &x[0] as *const _ as *const u32;
109
// This must fail because alignment is violated: the allocation's base is not sufficiently aligned.
1110
// The deref is UB even if we just put the result into a raw pointer.
12-
let _x = unsafe { ptr::raw_const!(*x) }; //~ ERROR memory with alignment 2, but alignment 4 is required
11+
let _x = unsafe { ptr::addr_of!(*x) }; //~ ERROR memory with alignment 2, but alignment 4 is required
1312
}
1413
}

tests/run-pass/packed_struct.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#![feature(unsize, coerce_unsized, raw_ref_op, raw_ref_macros)]
1+
#![feature(unsize, coerce_unsized)]
22

33
use std::collections::hash_map::DefaultHasher;
44
use std::hash::Hash;
@@ -46,9 +46,9 @@ fn test_basic() {
4646
assert_eq!({x.b}, 99);
4747
// but we *can* take a raw pointer!
4848
assert_eq!(unsafe { (&raw const x.a).read_unaligned() }, 42);
49-
assert_eq!(unsafe { ptr::raw_const!(x.a).read_unaligned() }, 42);
49+
assert_eq!(unsafe { ptr::addr_of!(x.a).read_unaligned() }, 42);
5050
assert_eq!(unsafe { (&raw const x.b).read_unaligned() }, 99);
51-
assert_eq!(unsafe { ptr::raw_const!(x.b).read_unaligned() }, 99);
51+
assert_eq!(unsafe { ptr::addr_of!(x.b).read_unaligned() }, 99);
5252

5353
x.b = 77;
5454
assert_eq!({x.b}, 77);

tests/run-pass/stacked-borrows/stacked-borrows.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// compile-flags: -Zmiri-track-raw-pointers
2-
#![feature(raw_ref_macros)]
32
use std::ptr;
43

54
// Test various stacked-borrows-related things.
@@ -169,8 +168,8 @@ fn raw_ref_to_part() {
169168
}
170169

171170
let it = Box::new(Whole { part: Part { _lame: 0 }, extra: 42 });
172-
let whole = ptr::raw_mut!(*Box::leak(it));
173-
let part = unsafe { ptr::raw_mut!((*whole).part) };
171+
let whole = ptr::addr_of_mut!(*Box::leak(it));
172+
let part = unsafe { ptr::addr_of_mut!((*whole).part) };
174173
let typed = unsafe { &mut *(part as *mut Whole) };
175174
assert!(typed.extra == 42);
176175
drop(unsafe { Box::from_raw(whole) });

0 commit comments

Comments
 (0)