Auto merge of #114689 - m-ou-se:stabilize-thread-local-cell-methods, r=thomcc

Stabilize thread local cell methods.

Closes #92122.
This commit is contained in:
bors 2023-08-16 02:37:29 +00:00
commit 656ee47db3
5 changed files with 9 additions and 22 deletions

View File

@ -35,7 +35,6 @@
#![feature(if_let_guard)] #![feature(if_let_guard)]
#![feature(inline_const)] #![feature(inline_const)]
#![feature(iter_from_generator)] #![feature(iter_from_generator)]
#![feature(local_key_cell_methods)]
#![feature(negative_impls)] #![feature(negative_impls)]
#![feature(never_type)] #![feature(never_type)]
#![feature(extern_types)] #![feature(extern_types)]

View File

@ -11,7 +11,6 @@
test(attr(allow(unused_variables), deny(warnings))) test(attr(allow(unused_variables), deny(warnings)))
)] )]
#![cfg_attr(not(feature = "default"), feature(rustc_private))] #![cfg_attr(not(feature = "default"), feature(rustc_private))]
#![feature(local_key_cell_methods)]
#![feature(ptr_metadata)] #![feature(ptr_metadata)]
#![feature(type_alias_impl_trait)] // Used to define opaque types. #![feature(type_alias_impl_trait)] // Used to define opaque types.
#![feature(intra_doc_pointers)] #![feature(intra_doc_pointers)]

View File

@ -24,7 +24,6 @@
#![feature(staged_api)] #![feature(staged_api)]
#![feature(allow_internal_unstable)] #![feature(allow_internal_unstable)]
#![feature(decl_macro)] #![feature(decl_macro)]
#![feature(local_key_cell_methods)]
#![feature(maybe_uninit_write_slice)] #![feature(maybe_uninit_write_slice)]
#![feature(negative_impls)] #![feature(negative_impls)]
#![feature(new_uninit)] #![feature(new_uninit)]

View File

@ -313,7 +313,6 @@ impl<T: 'static> LocalKey<Cell<T>> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(local_key_cell_methods)]
/// use std::cell::Cell; /// use std::cell::Cell;
/// ///
/// thread_local! { /// thread_local! {
@ -326,7 +325,7 @@ impl<T: 'static> LocalKey<Cell<T>> {
/// ///
/// assert_eq!(X.get(), 123); /// assert_eq!(X.get(), 123);
/// ``` /// ```
#[unstable(feature = "local_key_cell_methods", issue = "92122")] #[stable(feature = "local_key_cell_methods", since = "CURRENT_RUSTC_VERSION")]
pub fn set(&'static self, value: T) { pub fn set(&'static self, value: T) {
self.initialize_with(Cell::new(value), |value, cell| { self.initialize_with(Cell::new(value), |value, cell| {
if let Some(value) = value { if let Some(value) = value {
@ -351,7 +350,6 @@ impl<T: 'static> LocalKey<Cell<T>> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(local_key_cell_methods)]
/// use std::cell::Cell; /// use std::cell::Cell;
/// ///
/// thread_local! { /// thread_local! {
@ -360,7 +358,7 @@ impl<T: 'static> LocalKey<Cell<T>> {
/// ///
/// assert_eq!(X.get(), 1); /// assert_eq!(X.get(), 1);
/// ``` /// ```
#[unstable(feature = "local_key_cell_methods", issue = "92122")] #[stable(feature = "local_key_cell_methods", since = "CURRENT_RUSTC_VERSION")]
pub fn get(&'static self) -> T pub fn get(&'static self) -> T
where where
T: Copy, T: Copy,
@ -381,7 +379,6 @@ impl<T: 'static> LocalKey<Cell<T>> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(local_key_cell_methods)]
/// use std::cell::Cell; /// use std::cell::Cell;
/// ///
/// thread_local! { /// thread_local! {
@ -391,7 +388,7 @@ impl<T: 'static> LocalKey<Cell<T>> {
/// assert_eq!(X.take(), Some(1)); /// assert_eq!(X.take(), Some(1));
/// assert_eq!(X.take(), None); /// assert_eq!(X.take(), None);
/// ``` /// ```
#[unstable(feature = "local_key_cell_methods", issue = "92122")] #[stable(feature = "local_key_cell_methods", since = "CURRENT_RUSTC_VERSION")]
pub fn take(&'static self) -> T pub fn take(&'static self) -> T
where where
T: Default, T: Default,
@ -412,7 +409,6 @@ impl<T: 'static> LocalKey<Cell<T>> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(local_key_cell_methods)]
/// use std::cell::Cell; /// use std::cell::Cell;
/// ///
/// thread_local! { /// thread_local! {
@ -422,7 +418,7 @@ impl<T: 'static> LocalKey<Cell<T>> {
/// assert_eq!(X.replace(2), 1); /// assert_eq!(X.replace(2), 1);
/// assert_eq!(X.replace(3), 2); /// assert_eq!(X.replace(3), 2);
/// ``` /// ```
#[unstable(feature = "local_key_cell_methods", issue = "92122")] #[stable(feature = "local_key_cell_methods", since = "CURRENT_RUSTC_VERSION")]
pub fn replace(&'static self, value: T) -> T { pub fn replace(&'static self, value: T) -> T {
self.with(|cell| cell.replace(value)) self.with(|cell| cell.replace(value))
} }
@ -444,7 +440,6 @@ impl<T: 'static> LocalKey<RefCell<T>> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// #![feature(local_key_cell_methods)]
/// use std::cell::RefCell; /// use std::cell::RefCell;
/// ///
/// thread_local! { /// thread_local! {
@ -453,7 +448,7 @@ impl<T: 'static> LocalKey<RefCell<T>> {
/// ///
/// X.with_borrow(|v| assert!(v.is_empty())); /// X.with_borrow(|v| assert!(v.is_empty()));
/// ``` /// ```
#[unstable(feature = "local_key_cell_methods", issue = "92122")] #[stable(feature = "local_key_cell_methods", since = "CURRENT_RUSTC_VERSION")]
pub fn with_borrow<F, R>(&'static self, f: F) -> R pub fn with_borrow<F, R>(&'static self, f: F) -> R
where where
F: FnOnce(&T) -> R, F: FnOnce(&T) -> R,
@ -476,7 +471,6 @@ impl<T: 'static> LocalKey<RefCell<T>> {
/// # Example /// # Example
/// ///
/// ``` /// ```
/// #![feature(local_key_cell_methods)]
/// use std::cell::RefCell; /// use std::cell::RefCell;
/// ///
/// thread_local! { /// thread_local! {
@ -487,7 +481,7 @@ impl<T: 'static> LocalKey<RefCell<T>> {
/// ///
/// X.with_borrow(|v| assert_eq!(*v, vec![1])); /// X.with_borrow(|v| assert_eq!(*v, vec![1]));
/// ``` /// ```
#[unstable(feature = "local_key_cell_methods", issue = "92122")] #[stable(feature = "local_key_cell_methods", since = "CURRENT_RUSTC_VERSION")]
pub fn with_borrow_mut<F, R>(&'static self, f: F) -> R pub fn with_borrow_mut<F, R>(&'static self, f: F) -> R
where where
F: FnOnce(&mut T) -> R, F: FnOnce(&mut T) -> R,
@ -511,7 +505,6 @@ impl<T: 'static> LocalKey<RefCell<T>> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(local_key_cell_methods)]
/// use std::cell::RefCell; /// use std::cell::RefCell;
/// ///
/// thread_local! { /// thread_local! {
@ -524,7 +517,7 @@ impl<T: 'static> LocalKey<RefCell<T>> {
/// ///
/// X.with_borrow(|v| assert_eq!(*v, vec![1, 2, 3])); /// X.with_borrow(|v| assert_eq!(*v, vec![1, 2, 3]));
/// ``` /// ```
#[unstable(feature = "local_key_cell_methods", issue = "92122")] #[stable(feature = "local_key_cell_methods", since = "CURRENT_RUSTC_VERSION")]
pub fn set(&'static self, value: T) { pub fn set(&'static self, value: T) {
self.initialize_with(RefCell::new(value), |value, cell| { self.initialize_with(RefCell::new(value), |value, cell| {
if let Some(value) = value { if let Some(value) = value {
@ -551,7 +544,6 @@ impl<T: 'static> LocalKey<RefCell<T>> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(local_key_cell_methods)]
/// use std::cell::RefCell; /// use std::cell::RefCell;
/// ///
/// thread_local! { /// thread_local! {
@ -566,7 +558,7 @@ impl<T: 'static> LocalKey<RefCell<T>> {
/// ///
/// X.with_borrow(|v| assert!(v.is_empty())); /// X.with_borrow(|v| assert!(v.is_empty()));
/// ``` /// ```
#[unstable(feature = "local_key_cell_methods", issue = "92122")] #[stable(feature = "local_key_cell_methods", since = "CURRENT_RUSTC_VERSION")]
pub fn take(&'static self) -> T pub fn take(&'static self) -> T
where where
T: Default, T: Default,
@ -586,7 +578,6 @@ impl<T: 'static> LocalKey<RefCell<T>> {
/// # Examples /// # Examples
/// ///
/// ``` /// ```
/// #![feature(local_key_cell_methods)]
/// use std::cell::RefCell; /// use std::cell::RefCell;
/// ///
/// thread_local! { /// thread_local! {
@ -598,7 +589,7 @@ impl<T: 'static> LocalKey<RefCell<T>> {
/// ///
/// X.with_borrow(|v| assert_eq!(*v, vec![1, 2, 3])); /// X.with_borrow(|v| assert_eq!(*v, vec![1, 2, 3]));
/// ``` /// ```
#[unstable(feature = "local_key_cell_methods", issue = "92122")] #[stable(feature = "local_key_cell_methods", since = "CURRENT_RUSTC_VERSION")]
pub fn replace(&'static self, value: T) -> T { pub fn replace(&'static self, value: T) -> T {
self.with(|cell| cell.replace(value)) self.with(|cell| cell.replace(value))
} }

View File

@ -7,7 +7,6 @@
#![feature(variant_count)] #![feature(variant_count)]
#![feature(yeet_expr)] #![feature(yeet_expr)]
#![feature(nonzero_ops)] #![feature(nonzero_ops)]
#![feature(local_key_cell_methods)]
#![feature(round_ties_even)] #![feature(round_ties_even)]
#![feature(os_str_bytes)] #![feature(os_str_bytes)]
#![feature(lint_reasons)] #![feature(lint_reasons)]