Skip to content

Commit

Permalink
Rollup merge of rust-lang#88624 - kellerkindt:master, r=JohnTitor
Browse files Browse the repository at this point in the history
Stabilize feature `saturating_div` for rust 1.58.0

The tracking issue is rust-lang#89381

This seems like a reasonable simple change(?). The feature `saturating_div` was added as part of the ongoing effort to implement a `Saturating` integer type (see rust-lang#87921). The implementation has been discussed [here](rust-lang#87921 (comment)) and [here](rust-lang#87921 (comment)). It extends the list of saturating operations on integer types (like `saturating_add`, `saturating_sub`, `saturating_mul`, ...) by the function `fn saturating_div(self, rhs: Self) -> Self`.

The stabilization of the feature `saturating_int_impl` (for the `Saturating` type) needs to have this stabilized first.

Closes rust-lang#89381
  • Loading branch information
JohnTitor authored Oct 22, 2021
2 parents 121411d + 0dba9d0 commit 0c7b513
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 15 deletions.
7 changes: 1 addition & 6 deletions library/core/src/num/int_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1055,22 +1055,17 @@ macro_rules! int_impl {
/// Basic usage:
///
/// ```
/// #![feature(saturating_div)]
///
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".saturating_div(2), 2);")]
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MAX.saturating_div(-1), ", stringify!($SelfT), "::MIN + 1);")]
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.saturating_div(-1), ", stringify!($SelfT), "::MAX);")]
///
/// ```
///
/// ```should_panic
/// #![feature(saturating_div)]
///
#[doc = concat!("let _ = 1", stringify!($SelfT), ".saturating_div(0);")]
///
/// ```
#[unstable(feature = "saturating_div", issue = "87920")]
#[rustc_const_unstable(feature = "saturating_div", issue = "87920")]
#[stable(feature = "saturating_div", since = "1.58.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
Expand Down
4 changes: 2 additions & 2 deletions library/core/src/num/saturating.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ macro_rules! saturating_impl {
/// Basic usage:
///
/// ```
/// #![feature(saturating_int_impl, saturating_div)]
/// #![feature(saturating_int_impl)]
/// use std::num::Saturating;
///
#[doc = concat!("assert_eq!(Saturating(2", stringify!($t), "), Saturating(5", stringify!($t), ") / Saturating(2));")]
Expand All @@ -282,7 +282,7 @@ macro_rules! saturating_impl {
/// ```
///
/// ```should_panic
/// #![feature(saturating_int_impl, saturating_div)]
/// #![feature(saturating_int_impl)]
/// use std::num::Saturating;
///
#[doc = concat!("let _ = Saturating(0", stringify!($t), ") / Saturating(0);")]
Expand Down
7 changes: 1 addition & 6 deletions library/core/src/num/uint_macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1120,20 +1120,15 @@ macro_rules! uint_impl {
/// Basic usage:
///
/// ```
/// #![feature(saturating_div)]
///
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".saturating_div(2), 2);")]
///
/// ```
///
/// ```should_panic
/// #![feature(saturating_div)]
///
#[doc = concat!("let _ = 1", stringify!($SelfT), ".saturating_div(0);")]
///
/// ```
#[unstable(feature = "saturating_div", issue = "87920")]
#[rustc_const_unstable(feature = "saturating_div", issue = "87920")]
#[stable(feature = "saturating_div", since = "1.58.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
Expand Down
1 change: 0 additions & 1 deletion library/std/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,6 @@
#![feature(ptr_internals)]
#![feature(rustc_attrs)]
#![feature(rustc_private)]
#![feature(saturating_div)]
#![feature(saturating_int_impl)]
#![feature(slice_concat_ext)]
#![feature(slice_internals)]
Expand Down

0 comments on commit 0c7b513

Please sign in to comment.