rust-lang-nursery / lazy-static.rs

A small macro for defining lazy evaluated static variables in Rust.
Apache License 2.0
1.9k stars 111 forks source link

std::sync::ONCE_INIT is deprecated #151

Closed JacobEberhardt closed 5 years ago

JacobEberhardt commented 5 years ago

std::sync::ONCE_INIT is deprecated which leads to warnings when building. Would be great, if this could be replaced.

Built with rustc 1.38.0-nightly (6e310f2ab 2019-07-07)

Reproducible by building the example from readme.md. This results in the following warning: `warning: use of deprecated item 'lazy::std::sync::ONCE_INIT': the new function is now preferred --> src/inline_lazy.rs:14:9 14 pub use self::std::sync::ONCE_INIT; ^^^^^^^^^^^^^^^^^^^^^^^^^^

= note: #[warn(deprecated)] on by default`

BurntSushi commented 5 years ago

ONCE_INIT won't actually be deprecated for another two releases.

We should just add a targeted allow(deprecated) to its use of ONCE_INIT. There's not much point in bumping the MSRV from 1.24 to 1.31 just so Once::new can be used.

AxelNennker commented 5 years ago

Sorry for commenting on a closed issue... I am wondering whether you considered using https://github.com/dtolnay/rustversion So if the rustc version is 1.31 or newer use Once::new otherwise use ONCE_INIT Or something. Thanks for maintaining lazy_static