From 288cd55f3a02bfd831487f67391316362f5af7be Mon Sep 17 00:00:00 2001 From: Joshua Achorn Date: Thu, 3 May 2018 17:42:26 -0400 Subject: [PATCH 1/2] use new core unreachable API (fixes #96) --- src/nightly_lazy.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nightly_lazy.rs b/src/nightly_lazy.rs index 723222a..e7c3a6e 100644 --- a/src/nightly_lazy.rs +++ b/src/nightly_lazy.rs @@ -6,6 +6,7 @@ // copied, modified, or distributed except according to those terms. extern crate std; +extern crate core; use self::std::prelude::v1::*; use self::std::sync::Once; @@ -27,7 +28,7 @@ impl Lazy { unsafe { match self.0 { Some(ref x) => x, - None => std::mem::unreachable(), + None => core::hint::unreachable_unchecked(), } } } From afa05d22a557ef4b748e1ae804bd85cfb594aad0 Mon Sep 17 00:00:00 2001 From: Ashley Mannix Date: Thu, 17 May 2018 09:46:05 +1000 Subject: [PATCH 2/2] fix up compile tests --- .travis.yml | 4 +++- Cargo.toml | 5 ----- appveyor.yml | 6 ++++-- compiletest/Cargo.toml | 11 +++++++++++ compiletest/src/lib.rs | 13 +++++++++++++ {tests => compiletest/tests}/compile-fail/README.md | 2 +- .../incorrect_visibility_restriction.rs | 2 +- .../tests}/compile-fail/static_is_private.rs | 2 +- .../tests}/compile-fail/static_is_sized.rs | 2 +- .../tests}/compile-fail/static_never_used.rs | 2 +- {tests => compiletest/tests}/compile_tests.rs | 5 +++-- 11 files changed, 39 insertions(+), 15 deletions(-) create mode 100644 compiletest/Cargo.toml create mode 100644 compiletest/src/lib.rs rename {tests => compiletest/tests}/compile-fail/README.md (94%) rename {tests => compiletest/tests}/compile-fail/incorrect_visibility_restriction.rs (76%) rename {tests => compiletest/tests}/compile-fail/static_is_private.rs (81%) rename {tests => compiletest/tests}/compile-fail/static_is_sized.rs (75%) rename {tests => compiletest/tests}/compile-fail/static_never_used.rs (74%) rename {tests => compiletest/tests}/compile_tests.rs (93%) diff --git a/.travis.yml b/.travis.yml index 1f8894b..5a56115 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,10 @@ matrix: - cargo bench --features nightly - cargo test --features spin_no_std - cargo bench --features spin_no_std + - cd compiletest - cargo clean - - cargo test --features compiletest + - cargo test + - cd ../ - rust: nightly before_script: diff --git a/Cargo.toml b/Cargo.toml index eba4bd4..3dc0d3a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,14 +17,9 @@ categories = [ "no-std", "rust-patterns", "memory-management" ] version = "0.4.6" optional = true -[dependencies.compiletest_rs] -version = "0.3" -optional = true - [features] nightly = [] spin_no_std = ["nightly", "spin"] -compiletest = ["compiletest_rs"] [badges] appveyor = { repository = "rust-lang-nursery/lazy-static.rs" } diff --git a/appveyor.yml b/appveyor.yml index 82a726c..b138452 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -53,7 +53,9 @@ test_script: - cargo build --verbose - cargo test - if [%CHANNEL%]==[nightly] ( + cd compiletest && cargo clean && - cargo build --verbose --features "compiletest" && - cargo test --features "compiletest" + cargo build --verbose && + cargo test && + cd ../ ) diff --git a/compiletest/Cargo.toml b/compiletest/Cargo.toml new file mode 100644 index 0000000..e25d5a7 --- /dev/null +++ b/compiletest/Cargo.toml @@ -0,0 +1,11 @@ +[package] +name = "lazy_static_compiletest" +version = "0.0.1" +publish = false +authors = ["lazy_static contributors"] + +[dependencies.lazy_static] +path = "../" + +[dependencies.compiletest_rs] +version = "0.3" diff --git a/compiletest/src/lib.rs b/compiletest/src/lib.rs new file mode 100644 index 0000000..245f756 --- /dev/null +++ b/compiletest/src/lib.rs @@ -0,0 +1,13 @@ +/* +This library is a shim around `lazy_static` that disambiguates it with the `lazy_static` +that's shipped with the Rust toolchain. We re-export the entire public API of `lazy_static` +under a different crate name so that can be imported in the compile tests. + +This currently appears to use the right local build of `lazy_static`. +*/ + +#![feature(use_extern_macros)] + +extern crate lazy_static; + +pub use self::lazy_static::*; diff --git a/tests/compile-fail/README.md b/compiletest/tests/compile-fail/README.md similarity index 94% rename from tests/compile-fail/README.md rename to compiletest/tests/compile-fail/README.md index 7f80d11..58dbc3b 100644 --- a/tests/compile-fail/README.md +++ b/compiletest/tests/compile-fail/README.md @@ -3,7 +3,7 @@ warning/note/help/error at compilation. Syntax of annotations is described in [rust documentation](https://github.com/rust-lang/rust/blob/master/src/test/COMPILER_TESTS.md). For more information check out [`compiletest` crate](https://github.com/laumann/compiletest-rs). -To run compile tests issue `cargo +nightly --test --features compiletest`. +To run compile tests issue `cargo +nightly --test`. ## Notes on working with `compiletest` crate diff --git a/tests/compile-fail/incorrect_visibility_restriction.rs b/compiletest/tests/compile-fail/incorrect_visibility_restriction.rs similarity index 76% rename from tests/compile-fail/incorrect_visibility_restriction.rs rename to compiletest/tests/compile-fail/incorrect_visibility_restriction.rs index e2e5238..360e23d 100644 --- a/tests/compile-fail/incorrect_visibility_restriction.rs +++ b/compiletest/tests/compile-fail/incorrect_visibility_restriction.rs @@ -1,6 +1,6 @@ // incorrect visibility restriction #[macro_use] -extern crate lazy_static; +extern crate lazy_static_compiletest as lazy_static; lazy_static! { pub(nonsense) static ref WRONG: () = (); diff --git a/tests/compile-fail/static_is_private.rs b/compiletest/tests/compile-fail/static_is_private.rs similarity index 81% rename from tests/compile-fail/static_is_private.rs rename to compiletest/tests/compile-fail/static_is_private.rs index a88c1c6..6ebc8f5 100644 --- a/tests/compile-fail/static_is_private.rs +++ b/compiletest/tests/compile-fail/static_is_private.rs @@ -1,5 +1,5 @@ #[macro_use] -extern crate lazy_static; +extern crate lazy_static_compiletest as lazy_static; mod outer { pub mod inner { diff --git a/tests/compile-fail/static_is_sized.rs b/compiletest/tests/compile-fail/static_is_sized.rs similarity index 75% rename from tests/compile-fail/static_is_sized.rs rename to compiletest/tests/compile-fail/static_is_sized.rs index 3681ad7..e10ef22 100644 --- a/tests/compile-fail/static_is_sized.rs +++ b/compiletest/tests/compile-fail/static_is_sized.rs @@ -1,6 +1,6 @@ // error-pattern:the trait bound `str: std::marker::Sized` is not satisfied #[macro_use] -extern crate lazy_static; +extern crate lazy_static_compiletest as lazy_static; lazy_static! { pub static ref FOO: str = panic!(); diff --git a/tests/compile-fail/static_never_used.rs b/compiletest/tests/compile-fail/static_never_used.rs similarity index 74% rename from tests/compile-fail/static_never_used.rs rename to compiletest/tests/compile-fail/static_never_used.rs index a611778..744abbf 100644 --- a/tests/compile-fail/static_never_used.rs +++ b/compiletest/tests/compile-fail/static_never_used.rs @@ -1,7 +1,7 @@ // error-pattern:static item is never used: `UNUSED` #![deny(dead_code)] #[macro_use] -extern crate lazy_static; +extern crate lazy_static_compiletest as lazy_static; lazy_static! { static ref UNUSED: () = (); diff --git a/tests/compile_tests.rs b/compiletest/tests/compile_tests.rs similarity index 93% rename from tests/compile_tests.rs rename to compiletest/tests/compile_tests.rs index 3e347d5..d908077 100644 --- a/tests/compile_tests.rs +++ b/compiletest/tests/compile_tests.rs @@ -1,14 +1,15 @@ -#![cfg(feature="compiletest")] extern crate compiletest_rs as compiletest; fn run_mode(mode: &'static str) { let mut config = compiletest::Config::default(); config.mode = mode.parse().expect("Invalid mode"); config.src_base = ["tests", mode].iter().collect(); - config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps/".to_owned()); config.verbose = true; + config.target_rustcflags = Some("-L target/debug/ -L target/debug/deps/".to_owned()); + config.clean_rmeta(); + compiletest::run_tests(&config); }