Auto merge of #43750 - tbu-:pr_fn_unreachable, r=sfackler
Put `intrinsics::unreachable` on a possible path to stabilization Mark it with the `unreachable` feature and put it into the `mem` module. This is a pretty straight-forward API that can already be simulated in stable Rust by using `transmute` to create an uninhabited enum that can be matched.
This commit is contained in:
commit
a7e0d3a81f
2 changed files with 17 additions and 3 deletions
|
@ -629,10 +629,12 @@ extern "rust-intrinsic" {
|
||||||
/// Aborts the execution of the process.
|
/// Aborts the execution of the process.
|
||||||
pub fn abort() -> !;
|
pub fn abort() -> !;
|
||||||
|
|
||||||
/// Tells LLVM that this point in the code is not reachable,
|
/// Tells LLVM that this point in the code is not reachable, enabling
|
||||||
/// enabling further optimizations.
|
/// 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() -> !;
|
pub fn unreachable() -> !;
|
||||||
|
|
||||||
/// Informs the optimizer that a condition is always true.
|
/// Informs the optimizer that a condition is always true.
|
||||||
|
|
|
@ -942,3 +942,15 @@ impl<T: ::fmt::Debug> ::fmt::Debug for ManuallyDrop<T> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// 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()
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue