diff --git a/src/libcore/intrinsics.rs b/src/libcore/intrinsics.rs index 65c18d6d7772b..fdca8d00d7a75 100644 --- a/src/libcore/intrinsics.rs +++ b/src/libcore/intrinsics.rs @@ -629,10 +629,12 @@ extern "rust-intrinsic" { /// Aborts the execution of the process. pub fn abort() -> !; - /// Tells LLVM that this point in the code is not reachable, - /// enabling further optimizations. + /// Tells LLVM that this point in the code is not reachable, enabling + /// further optimizations. /// - /// NB: This is very different from the `unreachable!()` macro! + /// NB: This is very different from the `unreachable!()` macro: Unlike the + /// macro, which panics when it is executed, it is *undefined behavior* to + /// reach code marked with this function. pub fn unreachable() -> !; /// Informs the optimizer that a condition is always true. diff --git a/src/libcore/mem.rs b/src/libcore/mem.rs index 866296a567031..6f7adbe1e7a0e 100644 --- a/src/libcore/mem.rs +++ b/src/libcore/mem.rs @@ -942,3 +942,15 @@ impl ::fmt::Debug for ManuallyDrop { } } } + +/// Tells LLVM that this point in the code is not reachable, enabling further +/// optimizations. +/// +/// NB: This is very different from the `unreachable!()` macro: Unlike the +/// macro, which panics when it is executed, it is *undefined behavior* to +/// reach code marked with this function. +#[inline] +#[unstable(feature = "unreachable", issue = "43751")] +pub unsafe fn unreachable() -> ! { + intrinsics::unreachable() +}