Skip to content

Commit e8af475

Browse files
committed
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).
2 parents dc1e79b + 019ab5d commit e8af475

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/libcore/cell.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,8 @@ pub struct UnsafeCell<T: ?Sized> {
795795
///
796796
/// This field should not be accessed directly, it is made public for static
797797
/// initializers.
798+
#[deprecated(since = "1.2.0", reason = "use `get` to access the wrapped \
799+
value or `new` to initialize `UnsafeCell` in statics")]
798800
#[unstable(feature = "core")]
799801
pub value: T,
800802
}
@@ -818,6 +820,7 @@ impl<T> UnsafeCell<T> {
818820
#[stable(feature = "rust1", since = "1.0.0")]
819821
#[inline]
820822
pub const fn new(value: T) -> UnsafeCell<T> {
823+
#![allow(deprecated)]
821824
UnsafeCell { value: value }
822825
}
823826

@@ -839,7 +842,10 @@ impl<T> UnsafeCell<T> {
839842
/// ```
840843
#[inline]
841844
#[stable(feature = "rust1", since = "1.0.0")]
842-
pub unsafe fn into_inner(self) -> T { self.value }
845+
pub unsafe fn into_inner(self) -> T {
846+
#![allow(deprecated)]
847+
self.value
848+
}
843849
}
844850

845851
impl<T: ?Sized> UnsafeCell<T> {
@@ -859,6 +865,7 @@ impl<T: ?Sized> UnsafeCell<T> {
859865
pub fn get(&self) -> *mut T {
860866
// FIXME(#23542) Replace with type ascription.
861867
#![allow(trivial_casts)]
868+
#![allow(deprecated)]
862869
&self.value as *const T as *mut T
863870
}
864871
}

0 commit comments

Comments
 (0)