Skip to content

Commit b46d1d2

Browse files
Make wrapping arithmetic const
Co-Authored-By: 9999years <rbt@sent.as>
1 parent b422a19 commit b46d1d2

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

src/libcore/num/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1280,10 +1280,11 @@ assert_eq!((-128i8).wrapping_div(-1), -128);",
12801280
$EndFeature, "
12811281
```"),
12821282
#[stable(feature = "num_wrapping", since = "1.2.0")]
1283+
#[rustc_const_unstable(feature = "const_int_wrapping", issue = "53718")]
12831284
#[must_use = "this returns the result of the operation, \
12841285
without modifying the original"]
12851286
#[inline]
1286-
pub fn wrapping_div(self, rhs: Self) -> Self {
1287+
pub const fn wrapping_div(self, rhs: Self) -> Self {
12871288
self.overflowing_div(rhs).0
12881289
}
12891290
}
@@ -1340,10 +1341,11 @@ assert_eq!((-128i8).wrapping_rem(-1), 0);",
13401341
$EndFeature, "
13411342
```"),
13421343
#[stable(feature = "num_wrapping", since = "1.2.0")]
1344+
#[rustc_const_unstable(feature = "const_int_wrapping", issue = "53718")]
13431345
#[must_use = "this returns the result of the operation, \
13441346
without modifying the original"]
13451347
#[inline]
1346-
pub fn wrapping_rem(self, rhs: Self) -> Self {
1348+
pub const fn wrapping_rem(self, rhs: Self) -> Self {
13471349
self.overflowing_rem(rhs).0
13481350
}
13491351
}
@@ -3320,10 +3322,11 @@ Basic usage:
33203322
", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_div(10), 10);", $EndFeature, "
33213323
```"),
33223324
#[stable(feature = "num_wrapping", since = "1.2.0")]
3325+
#[rustc_const_unstable(feature = "const_int_wrapping", issue = "53718")]
33233326
#[must_use = "this returns the result of the operation, \
33243327
without modifying the original"]
33253328
#[inline]
3326-
pub fn wrapping_div(self, rhs: Self) -> Self {
3329+
pub const fn wrapping_div(self, rhs: Self) -> Self {
33273330
self / rhs
33283331
}
33293332
}
@@ -3371,10 +3374,11 @@ Basic usage:
33713374
", $Feature, "assert_eq!(100", stringify!($SelfT), ".wrapping_rem(10), 0);", $EndFeature, "
33723375
```"),
33733376
#[stable(feature = "num_wrapping", since = "1.2.0")]
3377+
#[rustc_const_unstable(feature = "const_int_wrapping", issue = "53718")]
33743378
#[must_use = "this returns the result of the operation, \
33753379
without modifying the original"]
33763380
#[inline]
3377-
pub fn wrapping_rem(self, rhs: Self) -> Self {
3381+
pub const fn wrapping_rem(self, rhs: Self) -> Self {
33783382
self % rhs
33793383
}
33803384
}

0 commit comments

Comments
 (0)