diff options
Diffstat (limited to 'lazy-static')
-rw-r--r-- | lazy-static/.travis.yml | 2 | ||||
-rw-r--r-- | lazy-static/Cargo.toml | 10 | ||||
-rw-r--r-- | lazy-static/README.md | 6 | ||||
-rw-r--r-- | lazy-static/src/inline_lazy.rs | 18 | ||||
-rw-r--r-- | lazy-static/src/lib.rs | 19 | ||||
-rw-r--r-- | lazy-static/tests/test.rs | 2 |
6 files changed, 27 insertions, 30 deletions
diff --git a/lazy-static/.travis.yml b/lazy-static/.travis.yml index f4c3c74..e4a0da3 100644 --- a/lazy-static/.travis.yml +++ b/lazy-static/.travis.yml @@ -1,7 +1,7 @@ language: rust matrix: include: - - rust: 1.24.1 + - rust: 1.27.2 - rust: stable script: - cargo test diff --git a/lazy-static/Cargo.toml b/lazy-static/Cargo.toml index 679f5cd..9c0a177 100644 --- a/lazy-static/Cargo.toml +++ b/lazy-static/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "lazy_static" # NB: When modifying, also modify html_root_url in lib.rs -version = "1.2.0" +version = "1.4.0" authors = ["Marvin Löbel <loebel.marvin@gmail.com>"] license = "MIT/Apache-2.0" @@ -15,15 +15,15 @@ categories = [ "no-std", "rust-patterns", "memory-management" ] exclude = ["/.travis.yml", "/appveyor.yml"] [dependencies.spin] -version = "0.4.10" +version = "0.5.0" optional = true -default-features = false -features = ["once"] [features] -nightly = [] spin_no_std = ["spin"] +[dev-dependencies] +doc-comment = "0.3.1" + [badges] appveyor = { repository = "rust-lang-nursery/lazy-static.rs" } travis-ci = { repository = "rust-lang-nursery/lazy-static.rs" } diff --git a/lazy-static/README.md b/lazy-static/README.md index d96cdf8..aa9f828 100644 --- a/lazy-static/README.md +++ b/lazy-static/README.md @@ -8,14 +8,14 @@ executed at runtime in order to be initialized. This includes anything requiring heap allocations, like vectors or hash maps, as well as anything that requires non-const function calls to be computed. -[![Travis-CI Status](https://travis-ci.org/rust-lang-nursery/lazy-static.rs.svg?branch=master)](https://travis-ci.org/rust-lang-nursery/lazy-static.rs) +[![Travis-CI Status](https://travis-ci.com/rust-lang-nursery/lazy-static.rs.svg?branch=master)](https://travis-ci.com/rust-lang-nursery/lazy-static.rs) [![Latest version](https://img.shields.io/crates/v/lazy_static.svg)](https://crates.io/crates/lazy_static) [![Documentation](https://docs.rs/lazy_static/badge.svg)](https://docs.rs/lazy_static) [![License](https://img.shields.io/crates/l/lazy_static.svg)](https://github.com/rust-lang-nursery/lazy-static.rs#license) ## Minimum supported `rustc` -`1.24.1+` +`1.27.2+` This version is explicitly tested in CI and may only be bumped in new minor versions. Any changes to the supported minimum version will be called out in the release notes. @@ -31,7 +31,7 @@ Add the following dependency to your Cargo manifest... ```toml [dependencies] -lazy_static = "1.2.0" +lazy_static = "1.4.0" ``` ...and see the [docs](https://docs.rs/lazy_static) for how to use it. diff --git a/lazy-static/src/inline_lazy.rs b/lazy-static/src/inline_lazy.rs index 268dd45..219ce9c 100644 --- a/lazy-static/src/inline_lazy.rs +++ b/lazy-static/src/inline_lazy.rs @@ -10,13 +10,16 @@ extern crate std; use self::std::prelude::v1::*; use self::std::cell::Cell; +use self::std::hint::unreachable_unchecked; use self::std::sync::Once; +#[allow(deprecated)] pub use self::std::sync::ONCE_INIT; -// FIXME: Replace Option<T> with MaybeInitialized<T> +// FIXME: Replace Option<T> with MaybeUninit<T> (stable since 1.36.0) pub struct Lazy<T: Sync>(Cell<Option<T>>, Once); impl<T: Sync> Lazy<T> { + #[allow(deprecated)] pub const INIT: Self = Lazy(Cell::new(None), ONCE_INIT); #[inline(always)] @@ -29,7 +32,7 @@ impl<T: Sync> Lazy<T> { }); // `self.0` is guaranteed to be `Some` by this point - // The `Once` will catch and propegate panics + // The `Once` will catch and propagate panics unsafe { match *self.0.as_ptr() { Some(ref x) => x, @@ -52,14 +55,3 @@ macro_rules! __lazy_static_create { static $NAME: $crate::lazy::Lazy<$T> = $crate::lazy::Lazy::INIT; }; } - -/// Polyfill for std::hint::unreachable_unchecked. There currently exists a -/// [crate](https://docs.rs/unreachable) for an equivalent to std::hint::unreachable_unchecked, but -/// lazy_static currently doesn't include any runtime dependencies and we've chosen to include this -/// short polyfill rather than include a new crate in every consumer's build. -/// -/// This should be replaced by std's version when lazy_static starts to require at least Rust 1.27. -unsafe fn unreachable_unchecked() -> ! { - enum Void {} - match std::mem::uninitialized::<Void>() {} -} diff --git a/lazy-static/src/lib.rs b/lazy-static/src/lib.rs index 42dc405..cada0dc 100644 --- a/lazy-static/src/lib.rs +++ b/lazy-static/src/lib.rs @@ -90,17 +90,13 @@ The `Deref` implementation uses a hidden static variable that is guarded by an a # Cargo features -This crate provides two cargo features: +This crate provides one cargo feature: -- `nightly`: This uses unstable language features only available on the nightly release channel for a more optimal implementation. In practice this currently means avoiding a heap allocation per static. This feature might get deprecated at a later point once all relevant optimizations are usable from stable. -- `spin_no_std` (implies `nightly`): This allows using this crate in a no-std environment, by depending on the standalone `spin` crate. - -Both features depend on unstable language features, which means -no guarantees can be made about them in regard to SemVer stability. +- `spin_no_std`: This allows using this crate in a no-std environment, by depending on the standalone `spin` crate. */ -#![doc(html_root_url = "https://docs.rs/lazy_static/1.2.0")] +#![doc(html_root_url = "https://docs.rs/lazy_static/1.4.0")] #![no_std] #[cfg(not(feature = "spin_no_std"))] @@ -108,6 +104,13 @@ no guarantees can be made about them in regard to SemVer stability. #[doc(hidden)] pub mod lazy; +#[cfg(test)] +#[macro_use] +extern crate doc_comment; + +#[cfg(test)] +doctest!("../README.md"); + #[cfg(feature = "spin_no_std")] #[path="core_lazy.rs"] #[doc(hidden)] @@ -196,7 +199,7 @@ pub trait LazyStatic { /// extern crate lazy_static; /// /// lazy_static! { -/// static ref BUFFER: Vec<u8> = (0..65537).collect(); +/// static ref BUFFER: Vec<u8> = (0..255).collect(); /// } /// /// fn main() { diff --git a/lazy-static/tests/test.rs b/lazy-static/tests/test.rs index 654abc5..03d0ab6 100644 --- a/lazy-static/tests/test.rs +++ b/lazy-static/tests/test.rs @@ -133,9 +133,11 @@ fn item_name_shadowing() { } use std::sync::atomic::AtomicBool; +#[allow(deprecated)] use std::sync::atomic::ATOMIC_BOOL_INIT; use std::sync::atomic::Ordering::SeqCst; +#[allow(deprecated)] static PRE_INIT_FLAG: AtomicBool = ATOMIC_BOOL_INIT; lazy_static! { |