Skip to content

Commit 32da2e2

Browse files
committed
Constifying many traits
1 parent cf4ef9a commit 32da2e2

File tree

6 files changed

+172
-76
lines changed

6 files changed

+172
-76
lines changed

‎library/core/src/num/nonzero.rs‎

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ where
299299
}
300300

301301
#[stable(feature = "nonzero_bitor", since = "1.45.0")]
302-
impl<T> BitOr for NonZero<T>
302+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
303+
impl<T> const BitOr for NonZero<T>
303304
where
304305
T: ZeroablePrimitive + BitOr<Output = T>,
305306
{
@@ -313,7 +314,8 @@ where
313314
}
314315

315316
#[stable(feature = "nonzero_bitor", since = "1.45.0")]
316-
impl<T> BitOr<T> for NonZero<T>
317+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
318+
impl<T> const BitOr<T> for NonZero<T>
317319
where
318320
T: ZeroablePrimitive + BitOr<Output = T>,
319321
{
@@ -327,7 +329,8 @@ where
327329
}
328330

329331
#[stable(feature = "nonzero_bitor", since = "1.45.0")]
330-
impl<T> BitOr<NonZero<T>> for T
332+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
333+
impl<T> const BitOr<NonZero<T>> for T
331334
where
332335
T: ZeroablePrimitive + BitOr<Output = T>,
333336
{
@@ -341,7 +344,8 @@ where
341344
}
342345

343346
#[stable(feature = "nonzero_bitor", since = "1.45.0")]
344-
impl<T> BitOrAssign for NonZero<T>
347+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
348+
impl<T> const BitOrAssign for NonZero<T>
345349
where
346350
T: ZeroablePrimitive,
347351
Self: BitOr<Output = Self>,
@@ -353,7 +357,8 @@ where
353357
}
354358

355359
#[stable(feature = "nonzero_bitor", since = "1.45.0")]
356-
impl<T> BitOrAssign<T> for NonZero<T>
360+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
361+
impl<T> const BitOrAssign<T> for NonZero<T>
357362
where
358363
T: ZeroablePrimitive,
359364
Self: BitOr<T, Output = Self>,
@@ -1228,7 +1233,8 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
12281233
// Impls for unsigned nonzero types only.
12291234
(unsigned $Int:ty) => {
12301235
#[stable(feature = "nonzero_div", since = "1.51.0")]
1231-
impl Div<NonZero<$Int>> for $Int {
1236+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
1237+
impl const Div<NonZero<$Int>> for $Int {
12321238
type Output = $Int;
12331239

12341240
/// Same as `self / other.get()`, but because `other` is a `NonZero<_>`,
@@ -1246,7 +1252,8 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
12461252
}
12471253

12481254
#[stable(feature = "nonzero_div_assign", since = "1.79.0")]
1249-
impl DivAssign<NonZero<$Int>> for $Int {
1255+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
1256+
impl const DivAssign<NonZero<$Int>> for $Int {
12501257
/// Same as `self /= other.get()`, but because `other` is a `NonZero<_>`,
12511258
/// there's never a runtime check for division-by-zero.
12521259
///
@@ -1259,7 +1266,8 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
12591266
}
12601267

12611268
#[stable(feature = "nonzero_div", since = "1.51.0")]
1262-
impl Rem<NonZero<$Int>> for $Int {
1269+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
1270+
impl const Rem<NonZero<$Int>> for $Int {
12631271
type Output = $Int;
12641272

12651273
/// This operation satisfies `n % d == n - (n / d) * d`, and cannot panic.
@@ -1272,7 +1280,8 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
12721280
}
12731281

12741282
#[stable(feature = "nonzero_div_assign", since = "1.79.0")]
1275-
impl RemAssign<NonZero<$Int>> for $Int {
1283+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
1284+
impl const RemAssign<NonZero<$Int>> for $Int {
12761285
/// This operation satisfies `n % d == n - (n / d) * d`, and cannot panic.
12771286
#[inline]
12781287
fn rem_assign(&mut self, other: NonZero<$Int>) {
@@ -1312,7 +1321,8 @@ macro_rules! nonzero_integer_signedness_dependent_impls {
13121321
// Impls for signed nonzero types only.
13131322
(signed $Int:ty) => {
13141323
#[stable(feature = "signed_nonzero_neg", since = "1.71.0")]
1315-
impl Neg for NonZero<$Int> {
1324+
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
1325+
impl const Neg for NonZero<$Int> {
13161326
type Output = Self;
13171327

13181328
#[inline]

0 commit comments

Comments
 (0)