From 38ab1569f019bd412e136339ca96e6b8f9913863 Mon Sep 17 00:00:00 2001 From: Konrad Borowski Date: Fri, 4 Oct 2019 23:59:37 +0200 Subject: [PATCH] Deprecate unreachable function This is designed to merged after #162, as it deprecates a function that should be no longer necessary on newer Rust versions. --- .travis.yml | 2 +- lib.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index ee744e1..2dc4702 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,6 @@ language: rust rust: - - 1.20.0 + - 1.36.0 - nightly - beta - stable diff --git a/lib.rs b/lib.rs index cedf2bd..62169d6 100644 --- a/lib.rs +++ b/lib.rs @@ -132,10 +132,9 @@ macro_rules! smallvec { /// /// Equivalent to `std::hint::unreachable_unchecked` but works in older versions of Rust. #[inline] +#[deprecated(note = "Use std::hint::unreachable_unchecked instead")] pub unsafe fn unreachable() -> ! { - enum Void {} - let x: &Void = mem::transmute(1usize); - match *x {} + std::hint::unreachable_unchecked() } /// `panic!()` in debug builds, optimization hint in release. @@ -144,7 +143,7 @@ macro_rules! debug_unreachable { () => { debug_unreachable!("entered unreachable code") }; ($e:expr) => { if cfg!(not(debug_assertions)) { - unreachable(); + std::hint::unreachable_unchecked(); } else { panic!($e); }