Skip to content

Commit 3eb9202

Browse files
Deprecated unreachable function
This is designed to merged after servo#162, as it deprecates a function that should be no longer necessary on newer Rust versions.
1 parent 3ee6d1e commit 3eb9202

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
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

+3-4
Original file line numberDiff line numberDiff line change
@@ -132,10 +132,9 @@ macro_rules! smallvec {
132132
///
133133
/// Equivalent to `std::hint::unreachable_unchecked` but works in older versions of Rust.
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)