Merge pull request #25 from gereeter/no-std

Support no_std in nodrop
This commit is contained in:
bluss
2016-02-06 19:27:07 +01:00
+9 -3
View File
@@ -17,13 +17,17 @@
#![cfg_attr(feature="no_drop_flag", feature(unsafe_no_drop_flag))] #![cfg_attr(feature="no_drop_flag", feature(unsafe_no_drop_flag))]
#![cfg_attr(feature="use_needs_drop", feature(core_intrinsics))] #![cfg_attr(feature="use_needs_drop", feature(core_intrinsics))]
#![cfg_attr(not(test), no_std)]
#[cfg(test)]
extern crate core;
extern crate odds; extern crate odds;
use odds::debug_assert_unreachable; use odds::debug_assert_unreachable;
use std::ops::{Deref, DerefMut}; use core::ops::{Deref, DerefMut};
use std::ptr; use core::ptr;
use std::mem; use core::mem;
/// repr(u8) - Make sure the non-nullable pointer optimization does not occur! /// repr(u8) - Make sure the non-nullable pointer optimization does not occur!
#[repr(u8)] #[repr(u8)]
@@ -107,6 +111,7 @@ impl<T> DerefMut for NoDrop<T> {
} }
} }
#[cfg(test)]
#[test] #[test]
fn test_no_nonnullable_opt() { fn test_no_nonnullable_opt() {
// Make sure `Flag` does not apply the non-nullable pointer optimization // Make sure `Flag` does not apply the non-nullable pointer optimization
@@ -116,6 +121,7 @@ fn test_no_nonnullable_opt() {
assert!(mem::size_of::<Option<Flag<&i32>>>() > mem::size_of::<Flag<&i32>>()); assert!(mem::size_of::<Option<Flag<&i32>>>() > mem::size_of::<Flag<&i32>>());
} }
#[cfg(test)]
#[test] #[test]
fn test_drop() { fn test_drop() {
use std::cell::Cell; use std::cell::Cell;