1
Fork 0

Stabilize remaining integer methods as const fn

This includes the following functions:
- i*::checked_div
- i*::checked_div_euclid
- i*::checked_rem
- i*::checked_rem_euclid
- i*::div_euclid
- i*::overflowing_div
- i*::overflowing_div_euclid
- i*::overflowing_rem
- i*::overflowing_rem_euclid
- i*::rem_euclid
- i*::wrapping_div
- i*::wrapping_div_euclid
- i*::wrapping_rem
- i*::wrapping_rem_euclid
- u*::checked_div
- u*::checked_div_euclid
- u*::checked_rem
- u*::checked_rem_euclid
- u*::div_euclid
- u*::overflowing_div
- u*::overflowing_div_euclid
- u*::overflowing_rem
- u*::overflowing_rem_euclid
- u*::rem_euclid
- u*::wrapping_div
- u*::wrapping_div_euclid
- u*::wrapping_rem
- u*::wrapping_rem_euclid
This commit is contained in:
Jacob Pratt 2021-01-13 04:57:28 -05:00
parent 7a9b552cb1
commit 265e03332b
No known key found for this signature in database
GPG key ID: B80E19E4662B5AA4
4 changed files with 32 additions and 36 deletions

View file

@ -513,7 +513,8 @@ macro_rules! int_impl {
#[doc = concat!("assert_eq!((1", stringify!($SelfT), ").checked_div(0), None);")]
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.51.0")]
#[rustc_allow_const_fn_unstable(const_int_unchecked_arith)]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
@ -539,7 +540,7 @@ macro_rules! int_impl {
#[doc = concat!("assert_eq!((1", stringify!($SelfT), ").checked_div_euclid(0), None);")]
/// ```
#[stable(feature = "euclidean_division", since = "1.38.0")]
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
@ -565,7 +566,8 @@ macro_rules! int_impl {
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_rem(-1), None);")]
/// ```
#[stable(feature = "wrapping", since = "1.7.0")]
#[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.51.0")]
#[rustc_allow_const_fn_unstable(const_int_unchecked_arith)]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
@ -591,7 +593,7 @@ macro_rules! int_impl {
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_rem_euclid(-1), None);")]
/// ```
#[stable(feature = "euclidean_division", since = "1.38.0")]
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
@ -949,7 +951,7 @@ macro_rules! int_impl {
/// assert_eq!((-128i8).wrapping_div(-1), -128);
/// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[rustc_const_unstable(feature = "const_wrapping_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
@ -977,7 +979,7 @@ macro_rules! int_impl {
/// assert_eq!((-128i8).wrapping_div_euclid(-1), -128);
/// ```
#[stable(feature = "euclidean_division", since = "1.38.0")]
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
@ -1005,7 +1007,7 @@ macro_rules! int_impl {
/// assert_eq!((-128i8).wrapping_rem(-1), 0);
/// ```
#[stable(feature = "num_wrapping", since = "1.2.0")]
#[rustc_const_unstable(feature = "const_wrapping_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
@ -1032,7 +1034,7 @@ macro_rules! int_impl {
/// assert_eq!((-128i8).wrapping_rem_euclid(-1), 0);
/// ```
#[stable(feature = "euclidean_division", since = "1.38.0")]
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
@ -1299,7 +1301,7 @@ macro_rules! int_impl {
/// ```
#[inline]
#[stable(feature = "wrapping", since = "1.7.0")]
#[rustc_const_unstable(feature = "const_overflowing_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool) {
@ -1329,7 +1331,7 @@ macro_rules! int_impl {
/// ```
#[inline]
#[stable(feature = "euclidean_division", since = "1.38.0")]
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) {
@ -1360,7 +1362,7 @@ macro_rules! int_impl {
/// ```
#[inline]
#[stable(feature = "wrapping", since = "1.7.0")]
#[rustc_const_unstable(feature = "const_overflowing_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
@ -1390,7 +1392,7 @@ macro_rules! int_impl {
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.overflowing_rem_euclid(-1), (0, true));")]
/// ```
#[stable(feature = "euclidean_division", since = "1.38.0")]
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
@ -1615,7 +1617,7 @@ macro_rules! int_impl {
/// assert_eq!((-a).div_euclid(-b), 2); // -7 >= -4 * 2
/// ```
#[stable(feature = "euclidean_division", since = "1.38.0")]
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]
@ -1653,7 +1655,7 @@ macro_rules! int_impl {
/// assert_eq!((-a).rem_euclid(-b), 1);
/// ```
#[stable(feature = "euclidean_division", since = "1.38.0")]
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
#[must_use = "this returns the result of the operation, \
without modifying the original"]
#[inline]