-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make use of core::hint::unreachable_unchecked
- Loading branch information
Showing
3 changed files
with
5 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,4 @@ | ||
use core::mem; | ||
|
||
pub unsafe fn deallocate<T>(ptr: *mut T, capacity: usize) { | ||
let _vec: Vec<T> = Vec::from_raw_parts(ptr, 0, capacity); | ||
// Let it drop. | ||
} | ||
|
||
/// Hint to the optimizer that any code path which calls this function is | ||
/// statically unreachable and can be removed. | ||
/// | ||
/// Equivalent to `std::hint::unreachable_unchecked` but works in older versions of Rust. | ||
#[inline] | ||
pub unsafe fn unreachable() -> ! { | ||
enum Void {} | ||
let x: &Void = mem::transmute(1usize); | ||
match *x {} | ||
} | ||
} |