Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
11 changes: 11 additions & 0 deletions src/libcore/mem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -942,3 +942,14 @@ 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.
#[unstable(feature = "unreachable", issue = "43751")]
pub unsafe fn unreachable() -> ! {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be #[inline] in order to allow optimizations to optimize it outside libcore?

intrinsics::unreachable()
}