diff options
Diffstat (limited to '')
-rw-r--r-- | tests/ui/const-ptr/forbidden_slices.rs (renamed from src/test/ui/const-ptr/forbidden_slices.rs) | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/src/test/ui/const-ptr/forbidden_slices.rs b/tests/ui/const-ptr/forbidden_slices.rs index e2184911f..192b6a46d 100644 --- a/src/test/ui/const-ptr/forbidden_slices.rs +++ b/tests/ui/const-ptr/forbidden_slices.rs @@ -1,6 +1,7 @@ -// stderr-per-bitwidth -// normalize-stderr-test "alloc[0-9]+" -> "ALLOC_ID" -// normalize-stderr-test "a[0-9]+\+0x" -> "A_ID+0x" +// Strip out raw byte dumps to make comparison platform-independent: +// normalize-stderr-test "(the raw bytes of the constant) \(size: [0-9]*, align: [0-9]*\)" -> "$1 (size: $$SIZE, align: $$ALIGN)" +// normalize-stderr-test "([0-9a-f][0-9a-f] |╾─*a(lloc)?[0-9]+(\+[a-z0-9]+)?─*╼ )+ *│.*" -> "HEX_DUMP" +// normalize-stderr-test "alloc\d+" -> "allocN" // error-pattern: could not evaluate static initializer #![feature( slice_from_ptr_range, @@ -31,7 +32,7 @@ pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; / // Reading padding is not ok pub static S7: &[u16] = unsafe { //~^ ERROR: it is undefined behavior to use this value - let ptr = (&D2 as *const Struct as *const u16).byte_add(1); + let ptr = (&D2 as *const Struct as *const u16).add(1); from_raw_parts(ptr, 4) }; @@ -65,13 +66,12 @@ pub static R6: &[bool] = unsafe { from_ptr_range(ptr..ptr.add(4)) }; pub static R7: &[u16] = unsafe { - //~^ ERROR: it is undefined behavior to use this value let ptr = (&D2 as *const Struct as *const u16).byte_add(1); - from_ptr_range(ptr..ptr.add(4)) + from_ptr_range(ptr..ptr.add(4)) //~ inside `R7` }; pub static R8: &[u64] = unsafe { let ptr = (&D4 as *const [u32; 2] as *const u32).byte_add(1).cast::<u64>(); - from_ptr_range(ptr..ptr.add(1)) + from_ptr_range(ptr..ptr.add(1)) //~ inside `R8` }; // This is sneaky: &D0 and &D0 point to different objects @@ -79,7 +79,7 @@ pub static R8: &[u64] = unsafe { pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).add(1)) }; pub static R10: &[u32] = unsafe { from_ptr_range(&D0..&D0) }; -const D0: u32 = 0x11; +const D0: u32 = 0x11111111; // Constant chosen for endianness-independent behavior. const D1: MaybeUninit<&u32> = MaybeUninit::uninit(); const D2: Struct = Struct { a: 1, b: 2, c: 3, d: 4 }; const D3: &u32 = &42; |