Skip to content

Commit 6704031

Browse files
authored
Unrolled build for #148333
Rollup merge of #148333 - bend-n:const_result_unwrap_unchecked, r=mark-simulacrum constify result unwrap unchecked constifies unwrap unchecked on result will make tracking issue if good
2 parents acda5e9 + edd7d8a commit 6704031

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

library/core/src/result.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,11 +1646,16 @@ impl<T, E> Result<T, E> {
16461646
#[inline]
16471647
#[track_caller]
16481648
#[stable(feature = "option_result_unwrap_unchecked", since = "1.58.0")]
1649-
pub unsafe fn unwrap_unchecked(self) -> T {
1649+
#[rustc_const_unstable(feature = "const_result_unwrap_unchecked", issue = "148714")]
1650+
pub const unsafe fn unwrap_unchecked(self) -> T {
16501651
match self {
16511652
Ok(t) => t,
1652-
// SAFETY: the safety contract must be upheld by the caller.
1653-
Err(_) => unsafe { hint::unreachable_unchecked() },
1653+
Err(e) => {
1654+
// FIXME(const-hack): to avoid E: const Destruct bound
1655+
super::mem::forget(e);
1656+
// SAFETY: the safety contract must be upheld by the caller.
1657+
unsafe { hint::unreachable_unchecked() }
1658+
}
16541659
}
16551660
}
16561661

0 commit comments

Comments
 (0)