Skip to content

Commit 48c9f1e

Browse files
committed
Make rem_euclid const
The implementation of rem_euclid for signed integers was const, but I'd forgotten to mark rem_euclid on unsigned integers as const as well, hence the failing test.
1 parent 70488cf commit 48c9f1e

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

src/libcore/num/mod.rs

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2232,7 +2232,7 @@ assert_eq!((-a).div_euclid(-b), 2); // -7 >= -4 * 2
22322232
/// No docs for bootstrap.
22332233
#[stable(feature = "euclidean_division", since = "1.38.0")]
22342234
#[must_use = "this returns the result of the operation, \
2235-
without modifying the original"]
2235+
without modifying the original"]
22362236
#[inline]
22372237
#[rustc_inherit_overflow_checks]
22382238
#[cfg(bootstrap)]
@@ -4414,11 +4414,24 @@ assert_eq!(7", stringify!($SelfT), ".rem_euclid(4), 3); // or any other integer
44144414
without modifying the original"]
44154415
#[inline]
44164416
#[rustc_inherit_overflow_checks]
4417-
pub fn rem_euclid(self, rhs: Self) -> Self {
4417+
#[rustc_const_unstable(feature = "const_int_euclidean")]
4418+
#[cfg(not(bootstrap))]
4419+
pub const fn rem_euclid(self, rhs: Self) -> Self {
44184420
self % rhs
44194421
}
44204422
}
44214423

4424+
/// No docs for bootstrap.
4425+
#[stable(feature = "euclidean_division", since = "1.38.0")]
4426+
#[must_use = "this returns the result of the operation, \
4427+
without modifying the original"]
4428+
#[inline]
4429+
#[rustc_inherit_overflow_checks]
4430+
#[cfg(bootstrap)]
4431+
pub fn rem_euclid(self, rhs: Self) -> Self {
4432+
self % rhs
4433+
}
4434+
44224435
doc_comment! {
44234436
concat!("Returns `true` if and only if `self == 2^k` for some `k`.
44244437

0 commit comments

Comments
 (0)