diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 1e3ed0f7c49f1..62b4a59d1801f 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -557,7 +557,7 @@ use crate::iter::{self, FusedIterator, TrustedLen}; use crate::panicking::{panic, panic_display}; use crate::pin::Pin; use crate::{ - cmp, convert, hint, mem, + cmp, convert, mem, ops::{self, ControlFlow, Deref, DerefMut}, slice, }; @@ -1037,7 +1037,7 @@ impl Option { match self { Some(val) => val, // SAFETY: the safety contract must be upheld by the caller. - None => unsafe { hint::unreachable_unchecked() }, + None => unsafe { mem::MaybeUninit::uninit().assume_init() }, } } diff --git a/library/core/src/result.rs b/library/core/src/result.rs index b2b627fe6a9cc..b1e15b1d1b28e 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -490,7 +490,7 @@ use crate::iter::{self, FusedIterator, TrustedLen}; use crate::ops::{self, ControlFlow, Deref, DerefMut}; -use crate::{convert, fmt, hint}; +use crate::{convert, fmt, mem}; /// `Result` is a type that represents either success ([`Ok`]) or failure ([`Err`]). /// @@ -1460,7 +1460,7 @@ impl Result { match self { Ok(t) => t, // SAFETY: the safety contract must be upheld by the caller. - Err(_) => unsafe { hint::unreachable_unchecked() }, + Err(_) => unsafe { mem::MaybeUninit::uninit().assume_init() }, } } @@ -1491,7 +1491,7 @@ impl Result { debug_assert!(self.is_err()); match self { // SAFETY: the safety contract must be upheld by the caller. - Ok(_) => unsafe { hint::unreachable_unchecked() }, + Ok(_) => unsafe { mem::MaybeUninit::uninit().assume_init() }, Err(e) => e, } }