diff --git a/.travis.yml b/.travis.yml index ba96dd4e..41ac09c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,6 +2,19 @@ language: rust matrix: include: + - env: TARGET=x86_64-unknown-linux-gnu + rust: beta + if: branch != master + + # wait for 1.29-beta + # - env: TARGET=thumbv6m-none-eabi + # rust: beta + # if: branch != master + + - env: TARGET=thumbv7m-none-eabi + rust: beta + if: branch != master + - env: TARGET=x86_64-unknown-linux-gnu rust: nightly diff --git a/ci/script.sh b/ci/script.sh index eafda3fd..335da344 100644 --- a/ci/script.sh +++ b/ci/script.sh @@ -1,22 +1,28 @@ set -euxo pipefail main() { - cargo check --target $TARGET + cargo check --target $TARGET --no-default-features + if [ $TRAVIS_RUST_VERSION = nightly ]; then + cargo check --target $TARGET + fi if [ $TARGET = x86_64-unknown-linux-gnu ]; then - cargo test --target $TARGET cargo test --target $TARGET --no-default-features - cargo test --target $TARGET --release cargo test --target $TARGET --release --no-default-features - export RUSTFLAGS="-Z sanitizer=thread" - export RUST_TEST_THREADS=1 - export TSAN_OPTIONS="suppressions=$(pwd)/blacklist.txt" + if [ $TRAVIS_RUST_VERSION = nightly ]; then + cargo test --target $TARGET + cargo test --target $TARGET --release - cargo test --test tsan --target $TARGET - cargo test --test tsan --target $TARGET --no-default-features - cargo test --test tsan --target $TARGET --release - cargo test --test tsan --target $TARGET --release --no-default-features + export RUSTFLAGS="-Z sanitizer=thread" + export RUST_TEST_THREADS=1 + export TSAN_OPTIONS="suppressions=$(pwd)/blacklist.txt" + + cargo test --test tsan --target $TARGET + cargo test --test tsan --target $TARGET --no-default-features + cargo test --test tsan --target $TARGET --release + cargo test --test tsan --target $TARGET --release --no-default-features + fi fi } diff --git a/src/__core.rs b/src/__core.rs index 763d0500..001a8024 100644 --- a/src/__core.rs +++ b/src/__core.rs @@ -1,51 +1,20 @@ /// Temporary fork of some stuff in `core` that's doesn't have a `const fn` API pub mod mem { - pub use core::mem::{replace, zeroed}; + #[cfg(not(feature = "const-fn"))] + pub use core::mem::uninitialized; + pub use core::mem::{replace, zeroed, ManuallyDrop}; - use core::ops::{Deref, DerefMut}; - - #[allow(unions_with_drop_fields)] - pub union ManuallyDrop { - value: T, - } - - impl ManuallyDrop { - #[inline] - const_fn!( - pub const fn new(value: T) -> ManuallyDrop { - ManuallyDrop { value: value } - } - ); - } - - impl Deref for ManuallyDrop { - type Target = T; - - #[inline] - fn deref(&self) -> &Self::Target { - unsafe { &self.value } + #[cfg(feature = "const-fn")] + pub const unsafe fn uninitialized() -> T { + #[allow(unions_with_drop_fields)] + union U { + none: (), + some: T, } + + U { none: () }.some } - - impl DerefMut for ManuallyDrop { - #[inline] - fn deref_mut(&mut self) -> &mut Self::Target { - unsafe { &mut self.value } - } - } - - const_fn!( - pub const unsafe fn uninitialized() -> T { - #[allow(unions_with_drop_fields)] - union U { - none: (), - some: T, - } - - U { none: () }.some - } - ); } #[cfg(feature = "const-fn")] // Remove this if there are more tests @@ -61,14 +30,16 @@ mod test { static mut I: i32 = unsafe { __core::mem::uninitialized() }; // Initialize before drop unsafe { core::ptr::write(&mut I as *mut i32, 42) }; - unsafe{ assert_eq!(I, 42) }; + unsafe { assert_eq!(I, 42) }; } #[cfg(feature = "const-fn")] #[test] fn static_new_manually_drop() { static mut M: ManuallyDrop = ManuallyDrop::new(42); - unsafe { assert_eq!(*M, 42); } + unsafe { + assert_eq!(*M, 42); + } // Drop before deinitialization unsafe { core::ptr::drop_in_place(&mut M as &mut i32 as *mut i32) }; } diff --git a/src/lib.rs b/src/lib.rs index 8f934071..dfa5463b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -83,8 +83,9 @@ #![deny(missing_docs)] #![deny(warnings)] #![cfg_attr(feature = "const-fn", feature(const_fn))] +#![cfg_attr(feature = "const-fn", feature(const_manually_drop_new))] +#![cfg_attr(feature = "const-fn", feature(untagged_unions))] #![cfg_attr(feature = "smaller-atomics", feature(core_intrinsics))] -#![feature(untagged_unions)] #![no_std] extern crate generic_array;