From 72e99f57c5118430361d23ed8e8815c1dd7271a5 Mon Sep 17 00:00:00 2001 From: Steven Fackler Date: Tue, 11 Jun 2019 18:57:48 -0700 Subject: Deprecate ONCE_INIT Once::new() has been a stable const fn for a while now. Closes #61746 --- src/libstd/sync/mod.rs | 1 + src/libstd/sync/once.rs | 5 +++++ 2 files changed, 6 insertions(+) (limited to 'src/libstd/sync') diff --git a/src/libstd/sync/mod.rs b/src/libstd/sync/mod.rs index 809ee882698..fd6e46fd61d 100644 --- a/src/libstd/sync/mod.rs +++ b/src/libstd/sync/mod.rs @@ -163,6 +163,7 @@ pub use self::condvar::{Condvar, WaitTimeoutResult}; #[stable(feature = "rust1", since = "1.0.0")] pub use self::mutex::{Mutex, MutexGuard}; #[stable(feature = "rust1", since = "1.0.0")] +#[allow(deprecated)] pub use self::once::{Once, OnceState, ONCE_INIT}; #[stable(feature = "rust1", since = "1.0.0")] pub use crate::sys_common::poison::{PoisonError, TryLockError, TryLockResult, LockResult}; diff --git a/src/libstd/sync/once.rs b/src/libstd/sync/once.rs index 0c912494024..e529b8c4227 100644 --- a/src/libstd/sync/once.rs +++ b/src/libstd/sync/once.rs @@ -115,6 +115,11 @@ pub struct OnceState { /// static START: Once = ONCE_INIT; /// ``` #[stable(feature = "rust1", since = "1.0.0")] +#[rustc_deprecated( + since = "1.38.0", + reason = "the `new` function is now preferred", + suggestion = "Once::new()", +)] pub const ONCE_INIT: Once = Once::new(); // Four states that a Once can be in, encoded into the lower bits of `state` in -- cgit 1.4.1-3-g733a5