Skip to content

Fix nightly build #99

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
5 changes: 0 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
6 changes: 4 additions & 2 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 ../
)
11 changes: 11 additions & 0 deletions compiletest/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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"
13 changes: 13 additions & 0 deletions compiletest/src/lib.rs
Original file line number Diff line number Diff line change
@@ -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::*;
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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: () = ();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[macro_use]
extern crate lazy_static;
extern crate lazy_static_compiletest as lazy_static;

mod outer {
pub mod inner {
Expand Down
Original file line number Diff line number Diff line change
@@ -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!();
Expand Down
Original file line number Diff line number Diff line change
@@ -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: () = ();
Expand Down
5 changes: 3 additions & 2 deletions tests/compile_tests.rs → compiletest/tests/compile_tests.rs
Original file line number Diff line number Diff line change
@@ -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);
}

Expand Down
3 changes: 2 additions & 1 deletion src/nightly_lazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -27,7 +28,7 @@ impl<T: Sync> Lazy<T> {
unsafe {
match self.0 {
Some(ref x) => x,
None => std::mem::unreachable(),
None => core::hint::unreachable_unchecked(),
}
}
}
Expand Down