Skip to content

Commit 3d67c90

Browse files
committed
Replace unreachable_unchecked with uninit().assume_init()
1 parent 02f7806 commit 3d67c90

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

library/core/src/option.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1037,7 +1037,7 @@ impl<T> Option<T> {
10371037
match self {
10381038
Some(val) => val,
10391039
// SAFETY: the safety contract must be upheld by the caller.
1040-
None => unsafe { hint::unreachable_unchecked() },
1040+
None => unsafe { mem::MaybeUninit::uninit().assume_init() },
10411041
}
10421042
}
10431043

library/core/src/result.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1460,7 +1460,7 @@ impl<T, E> Result<T, E> {
14601460
match self {
14611461
Ok(t) => t,
14621462
// SAFETY: the safety contract must be upheld by the caller.
1463-
Err(_) => unsafe { hint::unreachable_unchecked() },
1463+
Err(_) => unsafe { mem::MaybeUninit::uninit().assume_init() },
14641464
}
14651465
}
14661466

@@ -1491,7 +1491,7 @@ impl<T, E> Result<T, E> {
14911491
debug_assert!(self.is_err());
14921492
match self {
14931493
// SAFETY: the safety contract must be upheld by the caller.
1494-
Ok(_) => unsafe { hint::unreachable_unchecked() },
1494+
Ok(_) => unsafe { mem::MaybeUninit::uninit().assume_init() },
14951495
Err(e) => e,
14961496
}
14971497
}

0 commit comments

Comments
 (0)