mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-28 03:07:24 +03:00
Auto merge of #47204 - varkor:unsafecell-into_inner-safe, r=alexcrichton
Make UnsafeCell::into_inner safe This fixes #35067. It will require a Crater run as discussed in that issue.
This commit is contained in:
+4
-9
@@ -450,7 +450,7 @@ pub fn replace(&self, val: T) -> T {
|
||||
/// ```
|
||||
#[stable(feature = "move_cell", since = "1.17.0")]
|
||||
pub fn into_inner(self) -> T {
|
||||
unsafe { self.value.into_inner() }
|
||||
self.value.into_inner()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -569,7 +569,7 @@ pub fn into_inner(self) -> T {
|
||||
// compiler statically verifies that it is not currently borrowed.
|
||||
// Therefore the following assertion is just a `debug_assert!`.
|
||||
debug_assert!(self.borrow.get() == UNUSED);
|
||||
unsafe { self.value.into_inner() }
|
||||
self.value.into_inner()
|
||||
}
|
||||
|
||||
/// Replaces the wrapped value with a new one, returning the old value,
|
||||
@@ -1220,11 +1220,6 @@ pub const fn new(value: T) -> UnsafeCell<T> {
|
||||
|
||||
/// Unwraps the value.
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// This function is unsafe because this thread or another thread may currently be
|
||||
/// inspecting the inner value.
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```
|
||||
@@ -1232,11 +1227,11 @@ pub const fn new(value: T) -> UnsafeCell<T> {
|
||||
///
|
||||
/// let uc = UnsafeCell::new(5);
|
||||
///
|
||||
/// let five = unsafe { uc.into_inner() };
|
||||
/// let five = uc.into_inner();
|
||||
/// ```
|
||||
#[inline]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub unsafe fn into_inner(self) -> T {
|
||||
pub fn into_inner(self) -> T {
|
||||
self.value
|
||||
}
|
||||
}
|
||||
|
||||
@@ -285,7 +285,7 @@ pub fn get_mut(&mut self) -> &mut bool {
|
||||
#[inline]
|
||||
#[stable(feature = "atomic_access", since = "1.15.0")]
|
||||
pub fn into_inner(self) -> bool {
|
||||
unsafe { self.v.into_inner() != 0 }
|
||||
self.v.into_inner() != 0
|
||||
}
|
||||
|
||||
/// Loads a value from the bool.
|
||||
@@ -695,7 +695,7 @@ pub fn get_mut(&mut self) -> &mut *mut T {
|
||||
#[inline]
|
||||
#[stable(feature = "atomic_access", since = "1.15.0")]
|
||||
pub fn into_inner(self) -> *mut T {
|
||||
unsafe { self.p.into_inner() }
|
||||
self.p.into_inner()
|
||||
}
|
||||
|
||||
/// Loads a value from the pointer.
|
||||
@@ -1051,7 +1051,7 @@ pub fn get_mut(&mut self) -> &mut $int_type {
|
||||
#[inline]
|
||||
#[$stable_access]
|
||||
pub fn into_inner(self) -> $int_type {
|
||||
unsafe { self.v.into_inner() }
|
||||
self.v.into_inner()
|
||||
}
|
||||
|
||||
/// Loads a value from the atomic integer.
|
||||
|
||||
Reference in New Issue
Block a user