Rollup merge of #130972 - RalfJung:const_cell_into_inner, r=dtolnay · qinheping/verify-rust-std@b362019 (original) (raw)
`@@ -514,7 +514,8 @@ impl Cell {
`
514
514
`/// assert_eq!(five, 5);
`
515
515
```` /// ```
`516`
`516`
`#[stable(feature = "move_cell", since = "1.17.0")]
`
`517`
``
`-
#[rustc_const_unstable(feature = "const_cell_into_inner", issue = "78729")]
`
``
`517`
`+
#[rustc_const_stable(feature = "const_cell_into_inner", since = "CURRENT_RUSTC_VERSION")]
`
``
`518`
`+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
`
`518`
`519`
`pub const fn into_inner(self) -> T {
`
`519`
`520`
`self.value.into_inner()
`
`520`
`521`
`}
`
`@@ -857,7 +858,8 @@ impl<T> RefCell<T> {
`
`857`
`858`
`/// let five = c.into_inner();
`
`858`
`859`
```` /// ```
859
860
`#[stable(feature = "rust1", since = "1.0.0")]
`
860
``
`-
#[rustc_const_unstable(feature = "const_cell_into_inner", issue = "78729")]
`
``
861
`+
#[rustc_const_stable(feature = "const_cell_into_inner", since = "CURRENT_RUSTC_VERSION")]
`
``
862
`+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
`
861
863
`#[inline]
`
862
864
`pub const fn into_inner(self) -> T {
`
863
865
`` // Since this function takes self
(the RefCell
) by value, the
``
`@@ -2100,8 +2102,8 @@ impl UnsafeCell {
`
2100
2102
```` /// ```
````
2101
2103
`#[inline(always)]
`
2102
2104
`#[stable(feature = "rust1", since = "1.0.0")]
`
2103
``
`` -
// When this is const stabilized, please remove primitive_into_inner
below.
``
2104
``
`-
#[rustc_const_unstable(feature = "const_cell_into_inner", issue = "78729")]
`
``
2105
`+
#[rustc_const_stable(feature = "const_cell_into_inner", since = "CURRENT_RUSTC_VERSION")]
`
``
2106
`+
#[rustc_allow_const_fn_unstable(const_precise_live_drops)]
`
2105
2107
`pub const fn into_inner(self) -> T {
`
2106
2108
`self.value
`
2107
2109
`}
`
`@@ -2247,47 +2249,6 @@ impl<T: CoerceUnsized, U> CoerceUnsized<UnsafeCell> for UnsafeCell {}
`
2247
2249
`#[unstable(feature = "dispatch_from_dyn", issue = "none")]
`
2248
2250
`impl<T: DispatchFromDyn, U> DispatchFromDyn<UnsafeCell> for UnsafeCell {}
`
2249
2251
``
2250
``
`-
// Special cases of UnsafeCell::into_inner where T is a primitive. These are
`
2251
``
`-
// used by Atomic*::into_inner.
`
2252
``
`-
//
`
2253
``
`-
// The real UnsafeCell::into_inner cannot be used yet in a stable const function.
`
2254
``
`-
// That is blocked on a "precise drop analysis" unstable const feature.
`
2255
``
`-
// https://github.com/rust-lang/rust/issues/73255
`
2256
``
`-
macro_rules! unsafe_cell_primitive_into_inner {
`
2257
``
`-
($($primitive:ident $atomic:literal)*) => {
`
2258
``
`-
$(
`
2259
``
`-
#[cfg(target_has_atomic_load_store = $atomic)]
`
2260
``
`-
impl UnsafeCell<$primitive> {
`
2261
``
`-
pub(crate) const fn primitive_into_inner(self) -> $primitive {
`
2262
``
`-
self.value
`
2263
``
`-
}
`
2264
``
`-
}
`
2265
``
`-
)*
`
2266
``
`-
};
`
2267
``
`-
}
`
2268
``
-
2269
``
`-
unsafe_cell_primitive_into_inner! {
`
2270
``
`-
i8 "8"
`
2271
``
`-
u8 "8"
`
2272
``
`-
i16 "16"
`
2273
``
`-
u16 "16"
`
2274
``
`-
i32 "32"
`
2275
``
`-
u32 "32"
`
2276
``
`-
i64 "64"
`
2277
``
`-
u64 "64"
`
2278
``
`-
i128 "128"
`
2279
``
`-
u128 "128"
`
2280
``
`-
isize "ptr"
`
2281
``
`-
usize "ptr"
`
2282
``
`-
}
`
2283
``
-
2284
``
`-
#[cfg(target_has_atomic_load_store = "ptr")]
`
2285
``
`-
impl UnsafeCell<*mut T> {
`
2286
``
`-
pub(crate) const fn primitive_into_inner(self) -> *mut T {
`
2287
``
`-
self.value
`
2288
``
`-
}
`
2289
``
`-
}
`
2290
``
-
2291
2252
`` /// [UnsafeCell
], but [Sync
].
``
2292
2253
`///
`
2293
2254
`` /// This is just an UnsafeCell
, except it implements Sync
``