Skip to content

Commit

Permalink
Deprecate UnsafeCell::value
Browse files Browse the repository at this point in the history
  • Loading branch information
petrochenkov committed May 29, 2015
1 parent efebe45 commit bd962d9
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/libcore/cell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -641,6 +641,8 @@ pub struct UnsafeCell<T: ?Sized> {
///
/// This field should not be accessed directly, it is made public for static
/// initializers.
#[deprecated(since = "1.2.0", reason = "use `get` to access the wrapped value or `new` to
initialize `UnsafeCell` in statics")]
#[unstable(feature = "core")]
pub value: T,
}
Expand All @@ -664,6 +666,7 @@ impl<T> UnsafeCell<T> {
#[stable(feature = "rust1", since = "1.0.0")]
#[inline]
pub const fn new(value: T) -> UnsafeCell<T> {
#![allow(deprecated)]
UnsafeCell { value: value }
}

Expand All @@ -685,7 +688,10 @@ impl<T> UnsafeCell<T> {
/// ```
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn into_inner(self) -> T { self.value }
pub unsafe fn into_inner(self) -> T {
#![allow(deprecated)]
self.value
}
}

impl<T: ?Sized> UnsafeCell<T> {
Expand All @@ -705,6 +711,7 @@ impl<T: ?Sized> UnsafeCell<T> {
pub fn get(&self) -> *mut T {
// FIXME(#23542) Replace with type ascription.
#![allow(trivial_casts)]
#![allow(deprecated)]
&self.value as *const T as *mut T
}
}

0 comments on commit bd962d9

Please sign in to comment.