Skip to content

Commit

Permalink
Rollup merge of rust-lang#87910 - iago-lito:mark_unsafe_nonzero_arith…
Browse files Browse the repository at this point in the history
…metics_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.
  • Loading branch information
Manishearth committed Oct 4, 2021
2 parents 0f9e960 + 74c4c01 commit e500f1c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/core/src/num/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ macro_rules! nonzero_unsigned_operations {
/// ```
#[unstable(feature = "nonzero_ops", issue = "84186")]
#[inline]
pub unsafe fn unchecked_add(self, other: $Int) -> $Ty {
pub const unsafe fn unchecked_add(self, other: $Int) -> $Ty {
// SAFETY: The caller ensures there is no overflow.
unsafe { $Ty::new_unchecked(self.get().unchecked_add(other)) }
}
Expand Down Expand Up @@ -750,7 +750,7 @@ macro_rules! nonzero_unsigned_signed_operations {
/// ```
#[unstable(feature = "nonzero_ops", issue = "84186")]
#[inline]
pub unsafe fn unchecked_mul(self, other: $Ty) -> $Ty {
pub const unsafe fn unchecked_mul(self, other: $Ty) -> $Ty {
// SAFETY: The caller ensures there is no overflow.
unsafe { $Ty::new_unchecked(self.get().unchecked_mul(other.get())) }
}
Expand Down

0 comments on commit e500f1c

Please sign in to comment.