From af48cf63ee9b03801446ea9f14bdcba85b8035d5 Mon Sep 17 00:00:00 2001 From: Markus Reiter Date: Wed, 7 Feb 2024 16:00:12 +0100 Subject: [PATCH] Don't use `assert_unsafe_precondition` twice. --- library/core/src/num/nonzero.rs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/library/core/src/num/nonzero.rs b/library/core/src/num/nonzero.rs index 8cbbc2aa1a2..3d930c08318 100644 --- a/library/core/src/num/nonzero.rs +++ b/library/core/src/num/nonzero.rs @@ -3,6 +3,7 @@ use crate::cmp::Ordering; use crate::fmt; use crate::hash::{Hash, Hasher}; +use crate::intrinsics; #[cfg(bootstrap)] use crate::marker::StructuralEq; use crate::marker::StructuralPartialEq; @@ -11,7 +12,6 @@ use crate::str::FromStr; use super::from_str_radix; use super::{IntErrorKind, ParseIntError}; -use crate::intrinsics; mod private { #[unstable( @@ -115,12 +115,11 @@ where None => { // SAFETY: The caller guarantees that `n` is non-zero, so this is unreachable. unsafe { - crate::intrinsics::assert_unsafe_precondition!( - "NonZero::new_unchecked requires the argument to be non-zero", - () => false + intrinsics::assert_unsafe_precondition!( + "NonZero::new_unchecked requires the argument to be non-zero", + () => false, ); - - crate::hint::unreachable_unchecked() + intrinsics::unreachable() } } } @@ -155,12 +154,11 @@ where None => { // SAFETY: The caller guarantees that `n` references a value that is non-zero, so this is unreachable. unsafe { - crate::intrinsics::assert_unsafe_precondition!( + intrinsics::assert_unsafe_precondition!( "NonZero::from_mut_unchecked requires the argument to dereference as non-zero", - () => false + () => false, ); - - crate::hint::unreachable_unchecked() + intrinsics::unreachable() } } } @@ -770,7 +768,7 @@ macro_rules! nonzero_integer_signedness_dependent_impls { fn div(self, other: $Ty) -> $Int { // SAFETY: div by zero is checked because `other` is a nonzero, // and MIN/-1 is checked because `self` is an unsigned int. - unsafe { crate::intrinsics::unchecked_div(self, other.get()) } + unsafe { intrinsics::unchecked_div(self, other.get()) } } } @@ -783,7 +781,7 @@ macro_rules! nonzero_integer_signedness_dependent_impls { fn rem(self, other: $Ty) -> $Int { // SAFETY: rem by zero is checked because `other` is a nonzero, // and MIN/-1 is checked because `self` is an unsigned int. - unsafe { crate::intrinsics::unchecked_rem(self, other.get()) } + unsafe { intrinsics::unchecked_rem(self, other.get()) } } } };