Skip to content

Commit fdd2043

Browse files
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.
1 parent 3ee6d1e commit fdd2043

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: rust
22
rust:
3-
- 1.20.0
3+
- 1.36.0
44
- nightly
55
- beta
66
- stable

lib.rs

+4-5
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,11 @@ macro_rules! smallvec {
130130
/// Hint to the optimizer that any code path which calls this function is
131131
/// statically unreachable and can be removed.
132132
///
133-
/// Equivalent to `std::hint::unreachable_unchecked` but works in older versions of Rust.
133+
/// Equivalent to `std::hint::unreachable_unchecked`.
134134
#[inline]
135+
#[deprecated(note = "Use std::hint::unreachable_unchecked instead")]
135136
pub unsafe fn unreachable() -> ! {
136-
enum Void {}
137-
let x: &Void = mem::transmute(1usize);
138-
match *x {}
137+
std::hint::unreachable_unchecked()
139138
}
140139

141140
/// `panic!()` in debug builds, optimization hint in release.
@@ -144,7 +143,7 @@ macro_rules! debug_unreachable {
144143
() => { debug_unreachable!("entered unreachable code") };
145144
($e:expr) => {
146145
if cfg!(not(debug_assertions)) {
147-
unreachable();
146+
std::hint::unreachable_unchecked();
148147
} else {
149148
panic!($e);
150149
}

0 commit comments

Comments
 (0)