Skip to content

Commit a984702

Browse files
committed
Don't use assert_unsafe_precondition twice.
1 parent 3ed3e1b commit a984702

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

core/src/num/nonzero.rs

+10-12
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
use crate::cmp::Ordering;
44
use crate::fmt;
55
use crate::hash::{Hash, Hasher};
6+
use crate::intrinsics;
67
#[cfg(bootstrap)]
78
use crate::marker::StructuralEq;
89
use crate::marker::StructuralPartialEq;
@@ -11,7 +12,6 @@ use crate::str::FromStr;
1112

1213
use super::from_str_radix;
1314
use super::{IntErrorKind, ParseIntError};
14-
use crate::intrinsics;
1515

1616
mod private {
1717
#[unstable(
@@ -115,12 +115,11 @@ where
115115
None => {
116116
// SAFETY: The caller guarantees that `n` is non-zero, so this is unreachable.
117117
unsafe {
118-
crate::intrinsics::assert_unsafe_precondition!(
119-
"NonZero::new_unchecked requires the argument to be non-zero",
120-
() => false
118+
intrinsics::assert_unsafe_precondition!(
119+
"NonZero::new_unchecked requires the argument to be non-zero",
120+
() => false,
121121
);
122-
123-
crate::hint::unreachable_unchecked()
122+
intrinsics::unreachable()
124123
}
125124
}
126125
}
@@ -155,12 +154,11 @@ where
155154
None => {
156155
// SAFETY: The caller guarantees that `n` references a value that is non-zero, so this is unreachable.
157156
unsafe {
158-
crate::intrinsics::assert_unsafe_precondition!(
157+
intrinsics::assert_unsafe_precondition!(
159158
"NonZero::from_mut_unchecked requires the argument to dereference as non-zero",
160-
() => false
159+
() => false,
161160
);
162-
163-
crate::hint::unreachable_unchecked()
161+
intrinsics::unreachable()
164162
}
165163
}
166164
}
@@ -770,7 +768,7 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
770768
fn div(self, other: $Ty) -> $Int {
771769
// SAFETY: div by zero is checked because `other` is a nonzero,
772770
// and MIN/-1 is checked because `self` is an unsigned int.
773-
unsafe { crate::intrinsics::unchecked_div(self, other.get()) }
771+
unsafe { intrinsics::unchecked_div(self, other.get()) }
774772
}
775773
}
776774

@@ -783,7 +781,7 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
783781
fn rem(self, other: $Ty) -> $Int {
784782
// SAFETY: rem by zero is checked because `other` is a nonzero,
785783
// and MIN/-1 is checked because `self` is an unsigned int.
786-
unsafe { crate::intrinsics::unchecked_rem(self, other.get()) }
784+
unsafe { intrinsics::unchecked_rem(self, other.get()) }
787785
}
788786
}
789787
};

0 commit comments

Comments
 (0)