Skip to content
Open
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
11 changes: 8 additions & 3 deletions library/core/src/result.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1646,11 +1646,16 @@ impl<T, E> Result<T, E> {
#[inline]
#[track_caller]
#[stable(feature = "option_result_unwrap_unchecked", since = "1.58.0")]
pub unsafe fn unwrap_unchecked(self) -> T {
#[rustc_const_unstable(feature = "const_result_unwrap_unchecked", issue = "none")]
pub const unsafe fn unwrap_unchecked(self) -> T {
match self {
Ok(t) => t,
// SAFETY: the safety contract must be upheld by the caller.
Err(_) => unsafe { hint::unreachable_unchecked() },
Err(e) => {
// FIXME(const-hack): to avoid E: const Destruct bound
super::mem::forget(e);
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be annotated as a const hack so it can potentially be fixed later:

// FIXME(const-hack): to avoid E: const Destruct bound

// SAFETY: the safety contract must be upheld by the caller.
unsafe { hint::unreachable_unchecked() }
}
}
}

Expand Down
Loading