mirror of
https://github.com/rust-embedded/heapless.git
synced 2025-10-03 15:24:43 +00:00
Merge #48
48: move more feature gates behind a Cargo feature r=japaric a=japaric Co-authored-by: Jorge Aparicio <jorge@japaric.io>
This commit is contained in:
commit
e2fbadfd30
13
.travis.yml
13
.travis.yml
@ -2,6 +2,19 @@ language: rust
|
|||||||
|
|
||||||
matrix:
|
matrix:
|
||||||
include:
|
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
|
- env: TARGET=x86_64-unknown-linux-gnu
|
||||||
rust: nightly
|
rust: nightly
|
||||||
|
|
||||||
|
10
ci/script.sh
10
ci/script.sh
@ -1,14 +1,19 @@
|
|||||||
set -euxo pipefail
|
set -euxo pipefail
|
||||||
|
|
||||||
main() {
|
main() {
|
||||||
|
cargo check --target $TARGET --no-default-features
|
||||||
|
if [ $TRAVIS_RUST_VERSION = nightly ]; then
|
||||||
cargo check --target $TARGET
|
cargo check --target $TARGET
|
||||||
|
fi
|
||||||
|
|
||||||
if [ $TARGET = x86_64-unknown-linux-gnu ]; then
|
if [ $TARGET = x86_64-unknown-linux-gnu ]; then
|
||||||
cargo test --target $TARGET
|
|
||||||
cargo test --target $TARGET --no-default-features
|
cargo test --target $TARGET --no-default-features
|
||||||
cargo test --target $TARGET --release
|
|
||||||
cargo test --target $TARGET --release --no-default-features
|
cargo test --target $TARGET --release --no-default-features
|
||||||
|
|
||||||
|
if [ $TRAVIS_RUST_VERSION = nightly ]; then
|
||||||
|
cargo test --target $TARGET
|
||||||
|
cargo test --target $TARGET --release
|
||||||
|
|
||||||
export RUSTFLAGS="-Z sanitizer=thread"
|
export RUSTFLAGS="-Z sanitizer=thread"
|
||||||
export RUST_TEST_THREADS=1
|
export RUST_TEST_THREADS=1
|
||||||
export TSAN_OPTIONS="suppressions=$(pwd)/blacklist.txt"
|
export TSAN_OPTIONS="suppressions=$(pwd)/blacklist.txt"
|
||||||
@ -18,6 +23,7 @@ main() {
|
|||||||
cargo test --test tsan --target $TARGET --release
|
cargo test --test tsan --target $TARGET --release
|
||||||
cargo test --test tsan --target $TARGET --release --no-default-features
|
cargo test --test tsan --target $TARGET --release --no-default-features
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ $TRAVIS_BRANCH != master ]; then
|
if [ $TRAVIS_BRANCH != master ]; then
|
||||||
|
@ -1,41 +1,11 @@
|
|||||||
/// Temporary fork of some stuff in `core` that's doesn't have a `const fn` API
|
/// Temporary fork of some stuff in `core` that's doesn't have a `const fn` API
|
||||||
|
|
||||||
pub mod mem {
|
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};
|
#[cfg(feature = "const-fn")]
|
||||||
|
|
||||||
#[allow(unions_with_drop_fields)]
|
|
||||||
pub union ManuallyDrop<T> {
|
|
||||||
value: T,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> ManuallyDrop<T> {
|
|
||||||
#[inline]
|
|
||||||
const_fn!(
|
|
||||||
pub const fn new(value: T) -> ManuallyDrop<T> {
|
|
||||||
ManuallyDrop { value: value }
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> Deref for ManuallyDrop<T> {
|
|
||||||
type Target = T;
|
|
||||||
|
|
||||||
#[inline]
|
|
||||||
fn deref(&self) -> &Self::Target {
|
|
||||||
unsafe { &self.value }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl<T> DerefMut for ManuallyDrop<T> {
|
|
||||||
#[inline]
|
|
||||||
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
||||||
unsafe { &mut self.value }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const_fn!(
|
|
||||||
pub const unsafe fn uninitialized<T>() -> T {
|
pub const unsafe fn uninitialized<T>() -> T {
|
||||||
#[allow(unions_with_drop_fields)]
|
#[allow(unions_with_drop_fields)]
|
||||||
union U<T> {
|
union U<T> {
|
||||||
@ -45,7 +15,6 @@ pub mod mem {
|
|||||||
|
|
||||||
U { none: () }.some
|
U { none: () }.some
|
||||||
}
|
}
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "const-fn")] // Remove this if there are more tests
|
#[cfg(feature = "const-fn")] // Remove this if there are more tests
|
||||||
@ -68,7 +37,9 @@ mod test {
|
|||||||
#[test]
|
#[test]
|
||||||
fn static_new_manually_drop() {
|
fn static_new_manually_drop() {
|
||||||
static mut M: ManuallyDrop<i32> = ManuallyDrop::new(42);
|
static mut M: ManuallyDrop<i32> = ManuallyDrop::new(42);
|
||||||
unsafe { assert_eq!(*M, 42); }
|
unsafe {
|
||||||
|
assert_eq!(*M, 42);
|
||||||
|
}
|
||||||
// Drop before deinitialization
|
// Drop before deinitialization
|
||||||
unsafe { core::ptr::drop_in_place(&mut M as &mut i32 as *mut i32) };
|
unsafe { core::ptr::drop_in_place(&mut M as &mut i32 as *mut i32) };
|
||||||
}
|
}
|
||||||
|
@ -83,8 +83,9 @@
|
|||||||
#![deny(missing_docs)]
|
#![deny(missing_docs)]
|
||||||
#![deny(warnings)]
|
#![deny(warnings)]
|
||||||
#![cfg_attr(feature = "const-fn", feature(const_fn))]
|
#![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))]
|
#![cfg_attr(feature = "smaller-atomics", feature(core_intrinsics))]
|
||||||
#![feature(untagged_unions)]
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
|
|
||||||
extern crate generic_array;
|
extern crate generic_array;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user