summary refs log tree commit diff
path: root/library/alloc
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2021-01-10 19:35:42 +0100
committerRalf Jung <post@ralfj.de>2021-01-29 15:18:45 +0100
commit13ffa43bbb910b5484874f15e7bda824b8fe6782 (patch)
treeb5562247ac80565d6a675d40491717e27676e1a5 /library/alloc
parentd3163e96553ae8cb1fca0e62084b124e8b98310b (diff)
downloadrust-13ffa43bbb910b5484874f15e7bda824b8fe6782.tar.gz
rust-13ffa43bbb910b5484874f15e7bda824b8fe6782.zip
rename raw_const/mut -> const/mut_addr_of, and stabilize them
Diffstat (limited to 'library/alloc')
-rw-r--r--library/alloc/src/collections/btree/node.rs4
-rw-r--r--library/alloc/src/lib.rs1
-rw-r--r--library/alloc/src/rc.rs6
-rw-r--r--library/alloc/src/sync.rs6
4 files changed, 8 insertions, 9 deletions
diff --git a/library/alloc/src/collections/btree/node.rs b/library/alloc/src/collections/btree/node.rs
index 8ab3f58c1ad..9733b616662 100644
--- a/library/alloc/src/collections/btree/node.rs
+++ b/library/alloc/src/collections/btree/node.rs
@@ -543,8 +543,8 @@ impl<'a, K, V, Type> NodeRef<marker::ValMut<'a>, K, V, Type> {
         // to avoid aliasing with outstanding references to other elements,
         // in particular, those returned to the caller in earlier iterations.
         let leaf = Self::as_leaf_ptr(&mut self);
-        let keys = unsafe { &raw const (*leaf).keys };
-        let vals = unsafe { &raw mut (*leaf).vals };
+        let keys = unsafe { ptr::addr_of!((*leaf).keys) };
+        let vals = unsafe { ptr::addr_of_mut!((*leaf).vals) };
         // We must coerce to unsized array pointers because of Rust issue #74679.
         let keys: *const [_] = keys;
         let vals: *mut [_] = vals;
diff --git a/library/alloc/src/lib.rs b/library/alloc/src/lib.rs
index d7ae353282e..e10143b22d1 100644
--- a/library/alloc/src/lib.rs
+++ b/library/alloc/src/lib.rs
@@ -115,7 +115,6 @@
 #![feature(pattern)]
 #![feature(ptr_internals)]
 #![feature(range_bounds_assert_len)]
-#![feature(raw_ref_op)]
 #![feature(rustc_attrs)]
 #![feature(receiver_trait)]
 #![cfg_attr(bootstrap, feature(min_const_generics))]
diff --git a/library/alloc/src/rc.rs b/library/alloc/src/rc.rs
index ee03f15eece..f67f5fc533b 100644
--- a/library/alloc/src/rc.rs
+++ b/library/alloc/src/rc.rs
@@ -398,7 +398,7 @@ impl<T> Rc<T> {
 
         unsafe {
             let inner = init_ptr.as_ptr();
-            ptr::write(&raw mut (*inner).value, data);
+            ptr::write(ptr::addr_of_mut!((*inner).value), data);
 
             let prev_value = (*inner).strong.get();
             debug_assert_eq!(prev_value, 0, "No prior strong references should exist");
@@ -804,7 +804,7 @@ impl<T: ?Sized> Rc<T> {
         // SAFETY: This cannot go through Deref::deref or Rc::inner because
         // this is required to retain raw/mut provenance such that e.g. `get_mut` can
         // write through the pointer after the Rc is recovered through `from_raw`.
-        unsafe { &raw const (*ptr).value }
+        unsafe { ptr::addr_of_mut!((*ptr).value) }
     }
 
     /// Constructs an `Rc<T>` from a raw pointer.
@@ -1917,7 +1917,7 @@ impl<T: ?Sized> Weak<T> {
             // SAFETY: if is_dangling returns false, then the pointer is dereferencable.
             // The payload may be dropped at this point, and we have to maintain provenance,
             // so use raw pointer manipulation.
-            unsafe { &raw const (*ptr).value }
+            unsafe { ptr::addr_of_mut!((*ptr).value) }
         }
     }
 
diff --git a/library/alloc/src/sync.rs b/library/alloc/src/sync.rs
index c0d684fbb45..d0081097fe1 100644
--- a/library/alloc/src/sync.rs
+++ b/library/alloc/src/sync.rs
@@ -384,7 +384,7 @@ impl<T> Arc<T> {
         // reference into a strong reference.
         unsafe {
             let inner = init_ptr.as_ptr();
-            ptr::write(&raw mut (*inner).data, data);
+            ptr::write(ptr::addr_of_mut!((*inner).data), data);
 
             // The above write to the data field must be visible to any threads which
             // observe a non-zero strong count. Therefore we need at least "Release" ordering
@@ -800,7 +800,7 @@ impl<T: ?Sized> Arc<T> {
         // SAFETY: This cannot go through Deref::deref or RcBoxPtr::inner because
         // this is required to retain raw/mut provenance such that e.g. `get_mut` can
         // write through the pointer after the Rc is recovered through `from_raw`.
-        unsafe { &raw const (*ptr).data }
+        unsafe { ptr::addr_of_mut!((*ptr).data) }
     }
 
     /// Constructs an `Arc<T>` from a raw pointer.
@@ -1677,7 +1677,7 @@ impl<T: ?Sized> Weak<T> {
             // SAFETY: if is_dangling returns false, then the pointer is dereferencable.
             // The payload may be dropped at this point, and we have to maintain provenance,
             // so use raw pointer manipulation.
-            unsafe { &raw mut (*ptr).data }
+            unsafe { ptr::addr_of_mut!((*ptr).data) }
         }
     }