Skip to content

Commit

Permalink
Deprecate unreachable function
Browse files Browse the repository at this point in the history
This is designed to merged after #162, as it deprecates
a function that should be no longer necessary on newer
Rust versions.
  • Loading branch information
KamilaBorowska committed Oct 4, 2019
1 parent 3ee6d1e commit 38ab156
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
language: rust
rust:
- 1.20.0
- 1.36.0
- nightly
- beta
- stable
Expand Down
7 changes: 3 additions & 4 deletions lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}
Expand Down

0 comments on commit 38ab156

Please sign in to comment.