FEAT: nodrop: No odds dependency

Copy the required unreachable and debug assertion; saves us dependency
on odds.

We could also depend on crate unreachable, but that adds dep on
2 microcrates.
This commit is contained in:
bluss
2017-10-26 22:33:13 +02:00
parent f8a19cddd8
commit 7db0d5788f
2 changed files with 9 additions and 9 deletions
+1 -5
View File
@@ -17,7 +17,7 @@ default = ["std"]
# Default, requires Rust 1.6+ to disable
# Use libstd
std = ["odds/std"]
std = []
# Optional, Rust 1.21.0
# Use `needs_drop` to skip overwriting if not necessary
@@ -26,10 +26,6 @@ use_needs_drop = []
# Optional, nightly channel
use_union = ["nodrop-union"]
[dependencies.odds]
version = "0.2.12"
default-features = false
[dependencies.nodrop-union]
path = "../nodrop-union"
version = "0.1.8"
+8 -4
View File
@@ -19,9 +19,6 @@
#[cfg(not(any(test, feature="std")))]
extern crate core as std;
#[cfg(not(feature = "use_union"))]
extern crate odds;
#[cfg(feature = "use_union")]
extern crate nodrop_union as imp;
@@ -30,7 +27,6 @@ pub use imp::NoDrop;
#[cfg(not(feature = "use_union"))]
mod imp {
use odds::debug_assert_unreachable;
use std::ptr;
use std::mem;
use std::ops::{Deref, DerefMut};
@@ -125,6 +121,14 @@ mod imp {
assert!(mem::size_of::<Flag<&i32>>() > mem::size_of::<&i32>());
assert!(mem::size_of::<Flag<Vec<i32>>>() > mem::size_of::<Vec<i32>>());
}
// copying this code saves us microcrate deps
#[inline]
unsafe fn debug_assert_unreachable() -> ! {
debug_assert!(false, "Reached unreachable section: this is a bug!");
enum Void { }
match *(1 as *const Void) { }
}
}
#[cfg(test)]