From 7c92874782947e29a5297c3960b796ce6364c79a Mon Sep 17 00:00:00 2001 From: root Date: Tue, 2 Jun 2015 17:27:44 +0200 Subject: [PATCH] nodrop: Use odds & bump version --- nodrop/Cargo.toml | 5 ++++- nodrop/src/lib.rs | 22 ++++------------------ 2 files changed, 8 insertions(+), 19 deletions(-) diff --git a/nodrop/Cargo.toml b/nodrop/Cargo.toml index 493a869..97b5c8b 100644 --- a/nodrop/Cargo.toml +++ b/nodrop/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "nodrop" -version = "0.1.2" +version = "0.1.3" authors = ["bluss"] license = "MIT/Apache-2.0" @@ -16,3 +16,6 @@ keywords = ["container", "drop"] # Optional, nightly channel # Use no drop flag. See API doc for more info. no_drop_flag = [] + +[dependencies.odds] +version = "0.1" diff --git a/nodrop/src/lib.rs b/nodrop/src/lib.rs index 53d82f1..7a41c3c 100644 --- a/nodrop/src/lib.rs +++ b/nodrop/src/lib.rs @@ -12,6 +12,10 @@ #![cfg_attr(feature="no_drop_flag", feature(unsafe_no_drop_flag))] +extern crate odds; + +use odds::debug_assert_unreachable; + use std::ops::{Deref, DerefMut}; use std::ptr; use std::mem; @@ -58,24 +62,6 @@ impl Drop for NoDrop { } } -enum Void { } - -/// FIXME: Replace with intrinsic when it's stable -#[inline] -unsafe fn unreachable() -> ! { - let void: &Void = mem::transmute(&()); - match *void { - // no cases - } -} - -#[inline] -unsafe fn debug_assert_unreachable() -> ! { - debug_assert!(false, "Entered unreachable section, this is a bug!"); - unreachable() -} - - impl Deref for NoDrop { type Target = T;