Skip to content

Put intrinsics::unreachable on a possible path to stabilization #43750

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 11, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions src/libcore/intrinsics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}