@@ -54,6 +54,7 @@ use std::borrow::{Borrow, BorrowMut};
54
54
use std:: cmp;
55
55
use std:: fmt;
56
56
use std:: hash:: { Hash , Hasher } ;
57
+ use std:: hint:: unreachable_unchecked;
57
58
use std:: iter:: { IntoIterator , FromIterator , repeat} ;
58
59
use std:: mem;
59
60
use std:: mem:: ManuallyDrop ;
@@ -130,12 +131,11 @@ macro_rules! smallvec {
130
131
/// Hint to the optimizer that any code path which calls this function is
131
132
/// statically unreachable and can be removed.
132
133
///
133
- /// Equivalent to `std::hint::unreachable_unchecked` but works in older versions of Rust .
134
+ /// Equivalent to `std::hint::unreachable_unchecked`.
134
135
#[ inline]
136
+ #[ deprecated( note = "Use std::hint::unreachable_unchecked instead" ) ]
135
137
pub unsafe fn unreachable ( ) -> ! {
136
- enum Void { }
137
- let x: & Void = mem:: transmute ( 1usize ) ;
138
- match * x { }
138
+ unreachable_unchecked ( )
139
139
}
140
140
141
141
/// `panic!()` in debug builds, optimization hint in release.
@@ -144,7 +144,7 @@ macro_rules! debug_unreachable {
144
144
( ) => { debug_unreachable!( "entered unreachable code" ) } ;
145
145
( $e: expr) => {
146
146
if cfg!( not( debug_assertions) ) {
147
- unreachable ( ) ;
147
+ unreachable_unchecked ( ) ;
148
148
} else {
149
149
panic!( $e) ;
150
150
}
@@ -768,7 +768,7 @@ impl<A: Array> SmallVec<A> {
768
768
pub fn swap_remove ( & mut self , index : usize ) -> A :: Item {
769
769
let len = self . len ( ) ;
770
770
self . swap ( len - 1 , index) ;
771
- self . pop ( ) . unwrap_or_else ( || unsafe { unreachable ( ) } )
771
+ self . pop ( ) . unwrap_or_else ( || unsafe { unreachable_unchecked ( ) } )
772
772
}
773
773
774
774
/// Remove all elements from the vector.
0 commit comments