From 3d67c904ddf9d60a64926ea22dde26f026b37444 Mon Sep 17 00:00:00 2001 From: alion02 Date: Sun, 5 May 2024 06:18:21 +0200 Subject: [PATCH 1/4] Replace `unreachable_unchecked` with `uninit().assume_init()` --- library/core/src/option.rs | 2 +- library/core/src/result.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 1e3ed0f7c49f1..2a7bc92b98615 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -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..52e760311037c 100644 --- a/library/core/src/result.rs +++ b/library/core/src/result.rs @@ -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, } } From b0eca0b783ba36563d828db63732227bc6f2f4c0 Mon Sep 17 00:00:00 2001 From: alion02 Date: Sun, 5 May 2024 08:08:30 +0200 Subject: [PATCH 2/4] Fix build --- library/core/src/result.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library/core/src/result.rs b/library/core/src/result.rs index 52e760311037c..a74574c1d544e 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, hint, mem}; /// `Result` is a type that represents either success ([`Ok`]) or failure ([`Err`]). /// From 7456fd165b59fdac8fb4199a090a4adcd135b137 Mon Sep 17 00:00:00 2001 From: Jubilee <46493976+workingjubilee@users.noreply.github.com> Date: Sat, 4 May 2024 23:50:10 -0700 Subject: [PATCH 3/4] Really fix build (I think) --- library/core/src/option.rs | 2 +- library/core/src/result.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 2a7bc92b98615..88c7a73aa322c 100644 --- a/library/core/src/option.rs +++ b/library/core/src/option.rs @@ -1037,7 +1037,7 @@ impl Option { match self { Some(val) => val, // SAFETY: the safety contract must be upheld by the caller. - None => unsafe { mem::MaybeUninit::uninit().assume_init() }, + None => unsafe { MaybeUninit::uninit().assume_init() }, } } diff --git a/library/core/src/result.rs b/library/core/src/result.rs index a74574c1d544e..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, mem}; +use crate::{convert, fmt, mem}; /// `Result` is a type that represents either success ([`Ok`]) or failure ([`Err`]). /// From fd9898875659a115ff8ea3618e5994e91706ff72 Mon Sep 17 00:00:00 2001 From: Jubilee Young Date: Sat, 4 May 2024 23:56:10 -0700 Subject: [PATCH 4/4] Really really fix build --- library/core/src/option.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/library/core/src/option.rs b/library/core/src/option.rs index 88c7a73aa322c..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 { MaybeUninit::uninit().assume_init() }, + None => unsafe { mem::MaybeUninit::uninit().assume_init() }, } }