1
Fork 0

Auto merge of #25867 - petrochenkov:ucellv, r=alexcrichton

Now when const functions are implemented and used, the `value` field of `UnsafeCell` can be made deprecated (and then private as intended).
This commit is contained in:
bors 2015-06-02 23:23:32 +00:00
commit e8af4752ce

View file

@ -795,6 +795,8 @@ pub struct UnsafeCell<T: ?Sized> {
/// ///
/// This field should not be accessed directly, it is made public for static /// This field should not be accessed directly, it is made public for static
/// initializers. /// initializers.
#[deprecated(since = "1.2.0", reason = "use `get` to access the wrapped \
value or `new` to initialize `UnsafeCell` in statics")]
#[unstable(feature = "core")] #[unstable(feature = "core")]
pub value: T, pub value: T,
} }
@ -818,6 +820,7 @@ impl<T> UnsafeCell<T> {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
#[inline] #[inline]
pub const fn new(value: T) -> UnsafeCell<T> { pub const fn new(value: T) -> UnsafeCell<T> {
#![allow(deprecated)]
UnsafeCell { value: value } UnsafeCell { value: value }
} }
@ -839,7 +842,10 @@ impl<T> UnsafeCell<T> {
/// ``` /// ```
#[inline] #[inline]
#[stable(feature = "rust1", since = "1.0.0")] #[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> { impl<T: ?Sized> UnsafeCell<T> {
@ -859,6 +865,7 @@ impl<T: ?Sized> UnsafeCell<T> {
pub fn get(&self) -> *mut T { pub fn get(&self) -> *mut T {
// FIXME(#23542) Replace with type ascription. // FIXME(#23542) Replace with type ascription.
#![allow(trivial_casts)] #![allow(trivial_casts)]
#![allow(deprecated)]
&self.value as *const T as *mut T &self.value as *const T as *mut T
} }
} }