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:
+8
-4
@@ -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)]
|
||||
|
||||
Reference in New Issue
Block a user