From fe639057086fa7bef1e964bf3a211517b04bc328 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Sat, 18 Jul 2020 10:09:47 +1000 Subject: [PATCH] link once_cell feature to #74465 --- src/libcore/lazy.rs | 42 +++++++++++++++++----------------- src/libcore/lib.rs | 2 +- src/libstd/lazy.rs | 56 ++++++++++++++++++++++----------------------- src/libstd/lib.rs | 2 +- 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/libcore/lazy.rs b/src/libcore/lazy.rs index e9af66ff64264..5cf7217ef11e8 100644 --- a/src/libcore/lazy.rs +++ b/src/libcore/lazy.rs @@ -26,20 +26,20 @@ use crate::ops::Deref; /// assert_eq!(value, "Hello, World!"); /// assert!(cell.get().is_some()); /// ``` -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] pub struct OnceCell { // Invariant: written to at most once. inner: UnsafeCell>, } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl Default for OnceCell { fn default() -> Self { Self::new() } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl fmt::Debug for OnceCell { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.get() { @@ -49,7 +49,7 @@ impl fmt::Debug for OnceCell { } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl Clone for OnceCell { fn clone(&self) -> OnceCell { let res = OnceCell::new(); @@ -63,17 +63,17 @@ impl Clone for OnceCell { } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl PartialEq for OnceCell { fn eq(&self, other: &Self) -> bool { self.get() == other.get() } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl Eq for OnceCell {} -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl From for OnceCell { fn from(value: T) -> Self { OnceCell { inner: UnsafeCell::new(Some(value)) } @@ -82,7 +82,7 @@ impl From for OnceCell { impl OnceCell { /// Creates a new empty cell. - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub const fn new() -> OnceCell { OnceCell { inner: UnsafeCell::new(None) } } @@ -90,7 +90,7 @@ impl OnceCell { /// Gets the reference to the underlying value. /// /// Returns `None` if the cell is empty. - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn get(&self) -> Option<&T> { // Safety: Safe due to `inner`'s invariant unsafe { &*self.inner.get() }.as_ref() @@ -99,7 +99,7 @@ impl OnceCell { /// Gets the mutable reference to the underlying value. /// /// Returns `None` if the cell is empty. - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn get_mut(&mut self) -> Option<&mut T> { // Safety: Safe because we have unique access unsafe { &mut *self.inner.get() }.as_mut() @@ -127,7 +127,7 @@ impl OnceCell { /// /// assert!(cell.get().is_some()); /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn set(&self, value: T) -> Result<(), T> { // Safety: Safe because we cannot have overlapping mutable borrows let slot = unsafe { &*self.inner.get() }; @@ -168,7 +168,7 @@ impl OnceCell { /// let value = cell.get_or_init(|| unreachable!()); /// assert_eq!(value, &92); /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn get_or_init(&self, f: F) -> &T where F: FnOnce() -> T, @@ -206,7 +206,7 @@ impl OnceCell { /// assert_eq!(value, Ok(&92)); /// assert_eq!(cell.get(), Some(&92)) /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn get_or_try_init(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result, @@ -241,7 +241,7 @@ impl OnceCell { /// cell.set("hello".to_string()).unwrap(); /// assert_eq!(cell.into_inner(), Some("hello".to_string())); /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn into_inner(self) -> Option { // Because `into_inner` takes `self` by value, the compiler statically verifies // that it is not currently borrowed. So it is safe to move out `Option`. @@ -269,7 +269,7 @@ impl OnceCell { /// assert_eq!(cell.take(), Some("hello".to_string())); /// assert_eq!(cell.get(), None); /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn take(&mut self) -> Option { mem::take(self).into_inner() } @@ -298,13 +298,13 @@ impl OnceCell { /// // 92 /// // 92 /// ``` -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] pub struct Lazy T> { cell: OnceCell, init: Cell>, } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl fmt::Debug for Lazy { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Lazy").field("cell", &self.cell).field("init", &"..").finish() @@ -329,7 +329,7 @@ impl Lazy { /// assert_eq!(&*lazy, "HELLO, WORLD!"); /// # } /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub const fn new(init: F) -> Lazy { Lazy { cell: OnceCell::new(), init: Cell::new(Some(init)) } } @@ -353,7 +353,7 @@ impl T> Lazy { /// assert_eq!(Lazy::force(&lazy), &92); /// assert_eq!(&*lazy, &92); /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn force(this: &Lazy) -> &T { this.cell.get_or_init(|| match this.init.take() { Some(f) => f(), @@ -362,7 +362,7 @@ impl T> Lazy { } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl T> Deref for Lazy { type Target = T; fn deref(&self) -> &T { @@ -370,7 +370,7 @@ impl T> Deref for Lazy { } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl Default for Lazy { /// Creates a new lazy value using `Default` as the initializing function. fn default() -> Lazy { diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs index 1e6a27cff0ce1..7bd530c5fb10a 100644 --- a/src/libcore/lib.rs +++ b/src/libcore/lib.rs @@ -239,7 +239,7 @@ pub mod char; pub mod ffi; #[cfg(not(test))] // See #65860 pub mod iter; -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] pub mod lazy; pub mod option; pub mod panic; diff --git a/src/libstd/lazy.rs b/src/libstd/lazy.rs index 094eff17f8916..86e1cfae582e8 100644 --- a/src/libstd/lazy.rs +++ b/src/libstd/lazy.rs @@ -10,7 +10,7 @@ use crate::{ }; #[doc(inline)] -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] pub use core::lazy::*; /// A synchronization primitive which can be written to only once. @@ -38,7 +38,7 @@ pub use core::lazy::*; /// assert!(value.is_some()); /// assert_eq!(value.unwrap().as_str(), "Hello, World!"); /// ``` -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] pub struct SyncOnceCell { once: Once, // Whether or not the value is initialized is tracked by `state_and_queue`. @@ -50,24 +50,24 @@ pub struct SyncOnceCell { // scoped thread B, which fills the cell, which is // then destroyed by A. That is, destructor observes // a sent value. -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] unsafe impl Sync for SyncOnceCell {} -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] unsafe impl Send for SyncOnceCell {} -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl RefUnwindSafe for SyncOnceCell {} -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl UnwindSafe for SyncOnceCell {} -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl Default for SyncOnceCell { fn default() -> SyncOnceCell { SyncOnceCell::new() } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl fmt::Debug for SyncOnceCell { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self.get() { @@ -77,7 +77,7 @@ impl fmt::Debug for SyncOnceCell { } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl Clone for SyncOnceCell { fn clone(&self) -> SyncOnceCell { let cell = Self::new(); @@ -91,7 +91,7 @@ impl Clone for SyncOnceCell { } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl From for SyncOnceCell { fn from(value: T) -> Self { let cell = Self::new(); @@ -102,19 +102,19 @@ impl From for SyncOnceCell { } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl PartialEq for SyncOnceCell { fn eq(&self, other: &SyncOnceCell) -> bool { self.get() == other.get() } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl Eq for SyncOnceCell {} impl SyncOnceCell { /// Creates a new empty cell. - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub const fn new() -> SyncOnceCell { SyncOnceCell { once: Once::new(), value: UnsafeCell::new(MaybeUninit::uninit()) } } @@ -123,7 +123,7 @@ impl SyncOnceCell { /// /// Returns `None` if the cell is empty, or being initialized. This /// method never blocks. - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn get(&self) -> Option<&T> { if self.is_initialized() { // Safe b/c checked is_initialized @@ -136,7 +136,7 @@ impl SyncOnceCell { /// Gets the mutable reference to the underlying value. /// /// Returns `None` if the cell is empty. This method never blocks. - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn get_mut(&mut self) -> Option<&mut T> { if self.is_initialized() { // Safe b/c checked is_initialized and we have a unique access @@ -170,7 +170,7 @@ impl SyncOnceCell { /// assert_eq!(CELL.get(), Some(&92)); /// } /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn set(&self, value: T) -> Result<(), T> { let mut value = Some(value); self.get_or_init(|| value.take().unwrap()); @@ -209,7 +209,7 @@ impl SyncOnceCell { /// let value = cell.get_or_init(|| unreachable!()); /// assert_eq!(value, &92); /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn get_or_init(&self, f: F) -> &T where F: FnOnce() -> T, @@ -248,7 +248,7 @@ impl SyncOnceCell { /// assert_eq!(value, Ok(&92)); /// assert_eq!(cell.get(), Some(&92)) /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn get_or_try_init(&self, f: F) -> Result<&T, E> where F: FnOnce() -> Result, @@ -286,7 +286,7 @@ impl SyncOnceCell { /// cell.set("hello".to_string()).unwrap(); /// assert_eq!(cell.into_inner(), Some("hello".to_string())); /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn into_inner(mut self) -> Option { // Safety: Safe because we immediately free `self` without dropping let inner = unsafe { self.take_inner() }; @@ -318,7 +318,7 @@ impl SyncOnceCell { /// assert_eq!(cell.take(), Some("hello".to_string())); /// assert_eq!(cell.get(), None); /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn take(&mut self) -> Option { mem::take(self).into_inner() } @@ -428,13 +428,13 @@ impl Drop for SyncOnceCell { /// // Some("Hoyten") /// } /// ``` -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] pub struct SyncLazy T> { cell: SyncOnceCell, init: Cell>, } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl fmt::Debug for SyncLazy { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { f.debug_struct("Lazy").field("cell", &self.cell).field("init", &"..").finish() @@ -446,17 +446,17 @@ impl fmt::Debug for SyncLazy { // we do create a `&mut Option` in `force`, but this is // properly synchronized, so it only happens once // so it also does not contribute to this impl. -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] unsafe impl Sync for SyncLazy where SyncOnceCell: Sync {} // auto-derived `Send` impl is OK. -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl RefUnwindSafe for SyncLazy where SyncOnceCell: RefUnwindSafe {} impl SyncLazy { /// Creates a new lazy value with the given initializing /// function. - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub const fn new(f: F) -> SyncLazy { SyncLazy { cell: SyncOnceCell::new(), init: Cell::new(Some(f)) } } @@ -479,7 +479,7 @@ impl T> SyncLazy { /// assert_eq!(SyncLazy::force(&lazy), &92); /// assert_eq!(&*lazy, &92); /// ``` - #[unstable(feature = "once_cell", issue = "68198")] + #[unstable(feature = "once_cell", issue = "74465")] pub fn force(this: &SyncLazy) -> &T { this.cell.get_or_init(|| match this.init.take() { Some(f) => f(), @@ -488,7 +488,7 @@ impl T> SyncLazy { } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl T> Deref for SyncLazy { type Target = T; fn deref(&self) -> &T { @@ -496,7 +496,7 @@ impl T> Deref for SyncLazy { } } -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] impl Default for SyncLazy { /// Creates a new lazy value using `Default` as the initializing function. fn default() -> SyncLazy { diff --git a/src/libstd/lib.rs b/src/libstd/lib.rs index 8178719ccc40a..cf9cc4ebc7bd2 100644 --- a/src/libstd/lib.rs +++ b/src/libstd/lib.rs @@ -478,7 +478,7 @@ pub mod process; pub mod sync; pub mod time; -#[unstable(feature = "once_cell", issue = "68198")] +#[unstable(feature = "once_cell", issue = "74465")] pub mod lazy; #[stable(feature = "futures_api", since = "1.36.0")]