提交 a7e0d3a8 编写于 作者: B bors

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.
......@@ -629,10 +629,12 @@
/// 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.
......
......@@ -942,3 +942,15 @@ fn fmt(&self, fmt: &mut ::fmt::Formatter) -> ::fmt::Result {
}
}
}
/// 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()
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册