Skip to content

Commit deac382

Browse files
authored
Rollup merge of rust-lang#87910 - iago-lito:mark_unsafe_nonzero_arithmetics_as_const, r=joshtriplett
Mark unsafe methods NonZero*::unchecked_(add|mul) as const. Now that rust-lang/rfcs#3016 has landed, these two unstable `std` function can be marked `const`, according to this detail of rust-lang#84186.
2 parents ba39a0a + 74c4c01 commit deac382

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/core/src/num/nonzero.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ macro_rules! nonzero_unsigned_operations {
379379
/// ```
380380
#[unstable(feature = "nonzero_ops", issue = "84186")]
381381
#[inline]
382-
pub unsafe fn unchecked_add(self, other: $Int) -> $Ty {
382+
pub const unsafe fn unchecked_add(self, other: $Int) -> $Ty {
383383
// SAFETY: The caller ensures there is no overflow.
384384
unsafe { $Ty::new_unchecked(self.get().unchecked_add(other)) }
385385
}
@@ -750,7 +750,7 @@ macro_rules! nonzero_unsigned_signed_operations {
750750
/// ```
751751
#[unstable(feature = "nonzero_ops", issue = "84186")]
752752
#[inline]
753-
pub unsafe fn unchecked_mul(self, other: $Ty) -> $Ty {
753+
pub const unsafe fn unchecked_mul(self, other: $Ty) -> $Ty {
754754
// SAFETY: The caller ensures there is no overflow.
755755
unsafe { $Ty::new_unchecked(self.get().unchecked_mul(other.get())) }
756756
}

0 commit comments

Comments
 (0)