From ef428755381070b3e8053665120b8d015b42d029 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Sat, 30 Jan 2021 23:35:24 +0900 Subject: [PATCH] Rustup for rust-lang/rust#80886 --- rust-version | 2 +- .../dangling_pointers/dangling_pointer_addr_of.rs | 3 +-- tests/compile-fail/extern_static.rs | 3 +-- .../unaligned_pointers/unaligned_ptr_addr_of.rs | 3 +-- tests/run-pass/packed_struct.rs | 10 +++++----- tests/run-pass/stacked-borrows/stacked-borrows.rs | 5 ++--- 6 files changed, 11 insertions(+), 15 deletions(-) diff --git a/rust-version b/rust-version index 5752b651d2..efe541e603 100644 --- a/rust-version +++ b/rust-version @@ -1 +1 @@ -0e190206e2ff0c13d64701d9b4145bf89a2d0cab +7ce1b3b24491cbe10669cbe2b5733c2fe7cfe5b7 diff --git a/tests/compile-fail/dangling_pointers/dangling_pointer_addr_of.rs b/tests/compile-fail/dangling_pointers/dangling_pointer_addr_of.rs index 5df5b324f4..5de4138711 100644 --- a/tests/compile-fail/dangling_pointers/dangling_pointer_addr_of.rs +++ b/tests/compile-fail/dangling_pointers/dangling_pointer_addr_of.rs @@ -1,6 +1,5 @@ // Make sure we find these even with many checks disabled. // compile-flags: -Zmiri-disable-alignment-check -Zmiri-disable-stacked-borrows -Zmiri-disable-validation -#![feature(raw_ref_macros)] use std::ptr; fn main() { @@ -8,6 +7,6 @@ fn main() { let b = Box::new(42); &*b as *const i32 }; - let x = unsafe { ptr::raw_const!(*p) }; //~ ERROR dereferenced after this allocation got freed + let x = unsafe { ptr::addr_of!(*p) }; //~ ERROR dereferenced after this allocation got freed panic!("this should never print: {:?}", x); } diff --git a/tests/compile-fail/extern_static.rs b/tests/compile-fail/extern_static.rs index 650dfd0ac7..8fe8528146 100644 --- a/tests/compile-fail/extern_static.rs +++ b/tests/compile-fail/extern_static.rs @@ -1,4 +1,3 @@ -#![feature(raw_ref_op)] //! Even referencing an unknown `extern static` already triggers an error. extern "C" { @@ -6,5 +5,5 @@ extern "C" { } fn main() { - let _val = unsafe { &raw const FOO }; //~ ERROR is not supported by Miri + let _val = unsafe { ptr::addr_of_mut!(FOO) }; //~ ERROR is not supported by Miri } diff --git a/tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.rs b/tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.rs index 88e2634efa..e33f3c8598 100644 --- a/tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.rs +++ b/tests/compile-fail/unaligned_pointers/unaligned_ptr_addr_of.rs @@ -1,6 +1,5 @@ // This should fail even without validation or Stacked Borrows. // compile-flags: -Zmiri-disable-validation -Zmiri-disable-stacked-borrows -#![feature(raw_ref_macros)] use std::ptr; fn main() { @@ -9,6 +8,6 @@ fn main() { let x = &x[0] as *const _ as *const u32; // This must fail because alignment is violated: the allocation's base is not sufficiently aligned. // The deref is UB even if we just put the result into a raw pointer. - let _x = unsafe { ptr::raw_const!(*x) }; //~ ERROR memory with alignment 2, but alignment 4 is required + let _x = unsafe { ptr::addr_of!(*x) }; //~ ERROR memory with alignment 2, but alignment 4 is required } } diff --git a/tests/run-pass/packed_struct.rs b/tests/run-pass/packed_struct.rs index 43419695ba..aab968df9a 100644 --- a/tests/run-pass/packed_struct.rs +++ b/tests/run-pass/packed_struct.rs @@ -1,4 +1,4 @@ -#![feature(unsize, coerce_unsized, raw_ref_op, raw_ref_macros)] +#![feature(unsize, coerce_unsized)] use std::collections::hash_map::DefaultHasher; use std::hash::Hash; @@ -45,10 +45,10 @@ fn test_basic() { assert_eq!({x.a}, 42); assert_eq!({x.b}, 99); // but we *can* take a raw pointer! - assert_eq!(unsafe { (&raw const x.a).read_unaligned() }, 42); - assert_eq!(unsafe { ptr::raw_const!(x.a).read_unaligned() }, 42); - assert_eq!(unsafe { (&raw const x.b).read_unaligned() }, 99); - assert_eq!(unsafe { ptr::raw_const!(x.b).read_unaligned() }, 99); + assert_eq!(unsafe { ptr::addr_of_mut!(x.a).read_unaligned() }, 42); + assert_eq!(unsafe { ptr::addr_of!(x.a).read_unaligned() }, 42); + assert_eq!(unsafe { ptr::addr_of_mut!(x.b).read_unaligned() }, 99); + assert_eq!(unsafe { ptr::addr_of!(x.b).read_unaligned() }, 99); x.b = 77; assert_eq!({x.b}, 77); diff --git a/tests/run-pass/stacked-borrows/stacked-borrows.rs b/tests/run-pass/stacked-borrows/stacked-borrows.rs index 99bd0fb9d8..f76d4e64c6 100644 --- a/tests/run-pass/stacked-borrows/stacked-borrows.rs +++ b/tests/run-pass/stacked-borrows/stacked-borrows.rs @@ -1,5 +1,4 @@ // compile-flags: -Zmiri-track-raw-pointers -#![feature(raw_ref_macros)] use std::ptr; // Test various stacked-borrows-related things. @@ -169,8 +168,8 @@ fn raw_ref_to_part() { } let it = Box::new(Whole { part: Part { _lame: 0 }, extra: 42 }); - let whole = ptr::raw_mut!(*Box::leak(it)); - let part = unsafe { ptr::raw_mut!((*whole).part) }; + let whole = ptr::addr_of_mut!(*Box::leak(it)); + let part = unsafe { ptr::addr_of_mut!((*whole).part) }; let typed = unsafe { &mut *(part as *mut Whole) }; assert!(typed.extra == 42); drop(unsafe { Box::from_raw(whole) });