Skip to content

Commit

Permalink
Auto merge of #111044 - jmillikin:nonzero-negation, r=dtolnay
Browse files Browse the repository at this point in the history
Stabilize feature `nonzero_negation_ops`

Fixes #102443

ACP: rust-lang/libs-team#105
  • Loading branch information
bors committed May 16, 2023
2 parents ea54255 + bfa3e8a commit 76e79ca
Showing 1 changed file with 12 additions and 18 deletions.
30 changes: 12 additions & 18 deletions library/core/src/num/nonzero.rs
Original file line number Diff line number Diff line change
Expand Up @@ -756,8 +756,6 @@ macro_rules! nonzero_signed_operations {
/// # Example
///
/// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> {
Expand All @@ -771,7 +769,8 @@ macro_rules! nonzero_signed_operations {
/// ```
#[must_use]
#[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")]
#[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn is_positive(self) -> bool {
self.get().is_positive()
}
Expand All @@ -782,8 +781,6 @@ macro_rules! nonzero_signed_operations {
/// # Example
///
/// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> {
Expand All @@ -797,7 +794,8 @@ macro_rules! nonzero_signed_operations {
/// ```
#[must_use]
#[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")]
#[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn is_negative(self) -> bool {
self.get().is_negative()
}
Expand All @@ -807,8 +805,6 @@ macro_rules! nonzero_signed_operations {
/// # Example
///
/// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> {
Expand All @@ -823,7 +819,8 @@ macro_rules! nonzero_signed_operations {
/// # }
/// ```
#[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")]
#[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn checked_neg(self) -> Option<$Ty> {
if let Some(result) = self.get().checked_neg() {
// SAFETY: negation of nonzero cannot yield zero values.
Expand All @@ -840,8 +837,6 @@ macro_rules! nonzero_signed_operations {
/// # Example
///
/// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> {
Expand All @@ -856,7 +851,8 @@ macro_rules! nonzero_signed_operations {
/// # }
/// ```
#[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")]
#[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn overflowing_neg(self) -> ($Ty, bool) {
let (result, overflow) = self.get().overflowing_neg();
// SAFETY: negation of nonzero cannot yield zero values.
Expand All @@ -869,8 +865,6 @@ macro_rules! nonzero_signed_operations {
/// # Example
///
/// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> {
Expand All @@ -890,7 +884,8 @@ macro_rules! nonzero_signed_operations {
/// # }
/// ```
#[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")]
#[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn saturating_neg(self) -> $Ty {
if let Some(result) = self.checked_neg() {
return result;
Expand All @@ -907,8 +902,6 @@ macro_rules! nonzero_signed_operations {
/// # Example
///
/// ```
/// #![feature(nonzero_negation_ops)]
///
#[doc = concat!("# use std::num::", stringify!($Ty), ";")]
/// # fn main() { test().unwrap(); }
/// # fn test() -> Option<()> {
Expand All @@ -923,7 +916,8 @@ macro_rules! nonzero_signed_operations {
/// # }
/// ```
#[inline]
#[unstable(feature = "nonzero_negation_ops", issue = "102443")]
#[stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
#[rustc_const_stable(feature = "nonzero_negation_ops", since = "CURRENT_RUSTC_VERSION")]
pub const fn wrapping_neg(self) -> $Ty {
let result = self.get().wrapping_neg();
// SAFETY: negation of nonzero cannot yield zero values.
Expand Down

0 comments on commit 76e79ca

Please sign in to comment.