Skip to content

Commit 6d26895

Browse files
authored
Rollup merge of #91141 - jhpratt:int_roundings, r=joshtriplett
Revert "Temporarily rename int_roundings functions to avoid conflicts" This reverts commit 3ece63b. This should be okay because #90329 has been merged. r? `@joshtriplett`
2 parents 8f54061 + 41f70f3 commit 6d26895

File tree

4 files changed

+48
-48
lines changed

4 files changed

+48
-48
lines changed

library/core/src/num/int_macros.rs

+19-19
Original file line numberDiff line numberDiff line change
@@ -2025,17 +2025,17 @@ macro_rules! int_impl {
20252025
#[doc = concat!("let a: ", stringify!($SelfT)," = 8;")]
20262026
/// let b = 3;
20272027
///
2028-
/// assert_eq!(a.unstable_div_floor(b), 2);
2029-
/// assert_eq!(a.unstable_div_floor(-b), -3);
2030-
/// assert_eq!((-a).unstable_div_floor(b), -3);
2031-
/// assert_eq!((-a).unstable_div_floor(-b), 2);
2028+
/// assert_eq!(a.div_floor(b), 2);
2029+
/// assert_eq!(a.div_floor(-b), -3);
2030+
/// assert_eq!((-a).div_floor(b), -3);
2031+
/// assert_eq!((-a).div_floor(-b), 2);
20322032
/// ```
20332033
#[unstable(feature = "int_roundings", issue = "88581")]
20342034
#[must_use = "this returns the result of the operation, \
20352035
without modifying the original"]
20362036
#[inline]
20372037
#[rustc_inherit_overflow_checks]
2038-
pub const fn unstable_div_floor(self, rhs: Self) -> Self {
2038+
pub const fn div_floor(self, rhs: Self) -> Self {
20392039
let d = self / rhs;
20402040
let r = self % rhs;
20412041
if (r > 0 && rhs < 0) || (r < 0 && rhs > 0) {
@@ -2060,17 +2060,17 @@ macro_rules! int_impl {
20602060
#[doc = concat!("let a: ", stringify!($SelfT)," = 8;")]
20612061
/// let b = 3;
20622062
///
2063-
/// assert_eq!(a.unstable_div_ceil(b), 3);
2064-
/// assert_eq!(a.unstable_div_ceil(-b), -2);
2065-
/// assert_eq!((-a).unstable_div_ceil(b), -2);
2066-
/// assert_eq!((-a).unstable_div_ceil(-b), 3);
2063+
/// assert_eq!(a.div_ceil(b), 3);
2064+
/// assert_eq!(a.div_ceil(-b), -2);
2065+
/// assert_eq!((-a).div_ceil(b), -2);
2066+
/// assert_eq!((-a).div_ceil(-b), 3);
20672067
/// ```
20682068
#[unstable(feature = "int_roundings", issue = "88581")]
20692069
#[must_use = "this returns the result of the operation, \
20702070
without modifying the original"]
20712071
#[inline]
20722072
#[rustc_inherit_overflow_checks]
2073-
pub const fn unstable_div_ceil(self, rhs: Self) -> Self {
2073+
pub const fn div_ceil(self, rhs: Self) -> Self {
20742074
let d = self / rhs;
20752075
let r = self % rhs;
20762076
if (r > 0 && rhs > 0) || (r < 0 && rhs < 0) {
@@ -2095,21 +2095,21 @@ macro_rules! int_impl {
20952095
///
20962096
/// ```
20972097
/// #![feature(int_roundings)]
2098-
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".unstable_next_multiple_of(8), 16);")]
2099-
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".unstable_next_multiple_of(8), 24);")]
2100-
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".unstable_next_multiple_of(-8), 16);")]
2101-
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".unstable_next_multiple_of(-8), 16);")]
2102-
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").unstable_next_multiple_of(8), -16);")]
2103-
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").unstable_next_multiple_of(8), -16);")]
2104-
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").unstable_next_multiple_of(-8), -16);")]
2105-
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").unstable_next_multiple_of(-8), -24);")]
2098+
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(8), 16);")]
2099+
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(8), 24);")]
2100+
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(-8), 16);")]
2101+
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(-8), 16);")]
2102+
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").next_multiple_of(8), -16);")]
2103+
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").next_multiple_of(8), -16);")]
2104+
#[doc = concat!("assert_eq!((-16_", stringify!($SelfT), ").next_multiple_of(-8), -16);")]
2105+
#[doc = concat!("assert_eq!((-23_", stringify!($SelfT), ").next_multiple_of(-8), -24);")]
21062106
/// ```
21072107
#[unstable(feature = "int_roundings", issue = "88581")]
21082108
#[must_use = "this returns the result of the operation, \
21092109
without modifying the original"]
21102110
#[inline]
21112111
#[rustc_inherit_overflow_checks]
2112-
pub const fn unstable_next_multiple_of(self, rhs: Self) -> Self {
2112+
pub const fn next_multiple_of(self, rhs: Self) -> Self {
21132113
// This would otherwise fail when calculating `r` when self == T::MIN.
21142114
if rhs == -1 {
21152115
return self;

library/core/src/num/uint_macros.rs

+7-7
Original file line numberDiff line numberDiff line change
@@ -2024,14 +2024,14 @@ macro_rules! uint_impl {
20242024
///
20252025
/// ```
20262026
/// #![feature(int_roundings)]
2027-
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".unstable_div_floor(4), 1);")]
2027+
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".div_floor(4), 1);")]
20282028
/// ```
20292029
#[unstable(feature = "int_roundings", issue = "88581")]
20302030
#[must_use = "this returns the result of the operation, \
20312031
without modifying the original"]
20322032
#[inline(always)]
20332033
#[rustc_inherit_overflow_checks]
2034-
pub const fn unstable_div_floor(self, rhs: Self) -> Self {
2034+
pub const fn div_floor(self, rhs: Self) -> Self {
20352035
self / rhs
20362036
}
20372037

@@ -2047,14 +2047,14 @@ macro_rules! uint_impl {
20472047
///
20482048
/// ```
20492049
/// #![feature(int_roundings)]
2050-
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".unstable_div_ceil(4), 2);")]
2050+
#[doc = concat!("assert_eq!(7_", stringify!($SelfT), ".div_ceil(4), 2);")]
20512051
/// ```
20522052
#[unstable(feature = "int_roundings", issue = "88581")]
20532053
#[must_use = "this returns the result of the operation, \
20542054
without modifying the original"]
20552055
#[inline]
20562056
#[rustc_inherit_overflow_checks]
2057-
pub const fn unstable_div_ceil(self, rhs: Self) -> Self {
2057+
pub const fn div_ceil(self, rhs: Self) -> Self {
20582058
let d = self / rhs;
20592059
let r = self % rhs;
20602060
if r > 0 && rhs > 0 {
@@ -2077,15 +2077,15 @@ macro_rules! uint_impl {
20772077
///
20782078
/// ```
20792079
/// #![feature(int_roundings)]
2080-
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".unstable_next_multiple_of(8), 16);")]
2081-
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".unstable_next_multiple_of(8), 24);")]
2080+
#[doc = concat!("assert_eq!(16_", stringify!($SelfT), ".next_multiple_of(8), 16);")]
2081+
#[doc = concat!("assert_eq!(23_", stringify!($SelfT), ".next_multiple_of(8), 24);")]
20822082
/// ```
20832083
#[unstable(feature = "int_roundings", issue = "88581")]
20842084
#[must_use = "this returns the result of the operation, \
20852085
without modifying the original"]
20862086
#[inline]
20872087
#[rustc_inherit_overflow_checks]
2088-
pub const fn unstable_next_multiple_of(self, rhs: Self) -> Self {
2088+
pub const fn next_multiple_of(self, rhs: Self) -> Self {
20892089
match self % rhs {
20902090
0 => self,
20912091
r => self + (rhs - r)

library/core/tests/num/int_macros.rs

+17-17
Original file line numberDiff line numberDiff line change
@@ -294,33 +294,33 @@ macro_rules! int_module {
294294
fn test_div_floor() {
295295
let a: $T = 8;
296296
let b = 3;
297-
assert_eq!(a.unstable_div_floor(b), 2);
298-
assert_eq!(a.unstable_div_floor(-b), -3);
299-
assert_eq!((-a).unstable_div_floor(b), -3);
300-
assert_eq!((-a).unstable_div_floor(-b), 2);
297+
assert_eq!(a.div_floor(b), 2);
298+
assert_eq!(a.div_floor(-b), -3);
299+
assert_eq!((-a).div_floor(b), -3);
300+
assert_eq!((-a).div_floor(-b), 2);
301301
}
302302

303303
#[test]
304304
fn test_div_ceil() {
305305
let a: $T = 8;
306306
let b = 3;
307-
assert_eq!(a.unstable_div_ceil(b), 3);
308-
assert_eq!(a.unstable_div_ceil(-b), -2);
309-
assert_eq!((-a).unstable_div_ceil(b), -2);
310-
assert_eq!((-a).unstable_div_ceil(-b), 3);
307+
assert_eq!(a.div_ceil(b), 3);
308+
assert_eq!(a.div_ceil(-b), -2);
309+
assert_eq!((-a).div_ceil(b), -2);
310+
assert_eq!((-a).div_ceil(-b), 3);
311311
}
312312

313313
#[test]
314314
fn test_next_multiple_of() {
315-
assert_eq!((16 as $T).unstable_next_multiple_of(8), 16);
316-
assert_eq!((23 as $T).unstable_next_multiple_of(8), 24);
317-
assert_eq!((16 as $T).unstable_next_multiple_of(-8), 16);
318-
assert_eq!((23 as $T).unstable_next_multiple_of(-8), 16);
319-
assert_eq!((-16 as $T).unstable_next_multiple_of(8), -16);
320-
assert_eq!((-23 as $T).unstable_next_multiple_of(8), -16);
321-
assert_eq!((-16 as $T).unstable_next_multiple_of(-8), -16);
322-
assert_eq!((-23 as $T).unstable_next_multiple_of(-8), -24);
323-
assert_eq!(MIN.unstable_next_multiple_of(-1), MIN);
315+
assert_eq!((16 as $T).next_multiple_of(8), 16);
316+
assert_eq!((23 as $T).next_multiple_of(8), 24);
317+
assert_eq!((16 as $T).next_multiple_of(-8), 16);
318+
assert_eq!((23 as $T).next_multiple_of(-8), 16);
319+
assert_eq!((-16 as $T).next_multiple_of(8), -16);
320+
assert_eq!((-23 as $T).next_multiple_of(8), -16);
321+
assert_eq!((-16 as $T).next_multiple_of(-8), -16);
322+
assert_eq!((-23 as $T).next_multiple_of(-8), -24);
323+
assert_eq!(MIN.next_multiple_of(-1), MIN);
324324
}
325325

326326
#[test]

library/core/tests/num/uint_macros.rs

+5-5
Original file line numberDiff line numberDiff line change
@@ -208,19 +208,19 @@ macro_rules! uint_module {
208208

209209
#[test]
210210
fn test_div_floor() {
211-
assert_eq!((8 as $T).unstable_div_floor(3), 2);
211+
assert_eq!((8 as $T).div_floor(3), 2);
212212
}
213213

214214
#[test]
215215
fn test_div_ceil() {
216-
assert_eq!((8 as $T).unstable_div_ceil(3), 3);
216+
assert_eq!((8 as $T).div_ceil(3), 3);
217217
}
218218

219219
#[test]
220220
fn test_next_multiple_of() {
221-
assert_eq!((16 as $T).unstable_next_multiple_of(8), 16);
222-
assert_eq!((23 as $T).unstable_next_multiple_of(8), 24);
223-
assert_eq!(MAX.unstable_next_multiple_of(1), MAX);
221+
assert_eq!((16 as $T).next_multiple_of(8), 16);
222+
assert_eq!((23 as $T).next_multiple_of(8), 24);
223+
assert_eq!(MAX.next_multiple_of(1), MAX);
224224
}
225225

226226
#[test]

0 commit comments

Comments
 (0)