1
Fork 0

Rollup merge of #89876 - AlexApps99:const_ops, r=oli-obk

Make most std::ops traits const on numeric types

This PR makes existing implementations of `std::ops` traits (`Add`, `Sub`, etc) [`impl const`](https://github.com/rust-lang/rust/issues/67792) where possible.
This affects:
- All numeric primitives (`u*`, `i*`, `f*`)
- `NonZero*`
- `Wrapping`

This is under the `rustc_const_unstable` feature `const_ops`.
I will write tests once I know what can and can't be kept for the final version of this PR.

Since this is my first PR to rustc (and hopefully one of many), please give me feedback on how to better handle the PR process wherever possible. Thanks

[Zulip discussion](https://rust-lang.zulipchat.com/#narrow/stream/219381-t-libs/topic/Const.20std.3A.3Aops.20traits.20PR)
This commit is contained in:
Matthias Krüger 2021-10-30 14:36:58 +02:00 committed by GitHub
commit 20bb93210d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 235 additions and 106 deletions

View file

@ -5,6 +5,23 @@ macro_rules! forward_ref_unop {
forward_ref_unop!(impl $imp, $method for $t, forward_ref_unop!(impl $imp, $method for $t,
#[stable(feature = "rust1", since = "1.0.0")]); #[stable(feature = "rust1", since = "1.0.0")]);
}; };
(impl const $imp:ident, $method:ident for $t:ty) => {
forward_ref_unop!(impl const $imp, $method for $t,
#[stable(feature = "rust1", since = "1.0.0")]);
};
// Equivalent to the non-const version, with the addition of `rustc_const_unstable`
(impl const $imp:ident, $method:ident for $t:ty, #[$attr:meta]) => {
#[$attr]
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const $imp for &$t {
type Output = <$t as $imp>::Output;
#[inline]
fn $method(self) -> <$t as $imp>::Output {
$imp::$method(*self)
}
}
};
(impl $imp:ident, $method:ident for $t:ty, #[$attr:meta]) => { (impl $imp:ident, $method:ident for $t:ty, #[$attr:meta]) => {
#[$attr] #[$attr]
impl $imp for &$t { impl $imp for &$t {
@ -25,6 +42,45 @@ macro_rules! forward_ref_binop {
forward_ref_binop!(impl $imp, $method for $t, $u, forward_ref_binop!(impl $imp, $method for $t, $u,
#[stable(feature = "rust1", since = "1.0.0")]); #[stable(feature = "rust1", since = "1.0.0")]);
}; };
(impl const $imp:ident, $method:ident for $t:ty, $u:ty) => {
forward_ref_binop!(impl const $imp, $method for $t, $u,
#[stable(feature = "rust1", since = "1.0.0")]);
};
// Equivalent to the non-const version, with the addition of `rustc_const_unstable`
(impl const $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => {
#[$attr]
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl<'a> const $imp<$u> for &'a $t {
type Output = <$t as $imp<$u>>::Output;
#[inline]
fn $method(self, other: $u) -> <$t as $imp<$u>>::Output {
$imp::$method(*self, other)
}
}
#[$attr]
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const $imp<&$u> for $t {
type Output = <$t as $imp<$u>>::Output;
#[inline]
fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output {
$imp::$method(self, *other)
}
}
#[$attr]
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const $imp<&$u> for &$t {
type Output = <$t as $imp<$u>>::Output;
#[inline]
fn $method(self, other: &$u) -> <$t as $imp<$u>>::Output {
$imp::$method(*self, *other)
}
}
};
(impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => { (impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => {
#[$attr] #[$attr]
impl<'a> $imp<$u> for &'a $t { impl<'a> $imp<$u> for &'a $t {
@ -65,6 +121,21 @@ macro_rules! forward_ref_op_assign {
forward_ref_op_assign!(impl $imp, $method for $t, $u, forward_ref_op_assign!(impl $imp, $method for $t, $u,
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]); #[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]);
}; };
(impl const $imp:ident, $method:ident for $t:ty, $u:ty) => {
forward_ref_op_assign!(impl const $imp, $method for $t, $u,
#[stable(feature = "op_assign_builtins_by_ref", since = "1.22.0")]);
};
// Equivalent to the non-const version, with the addition of `rustc_const_unstable`
(impl const $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => {
#[$attr]
#[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const $imp<&$u> for $t {
#[inline]
fn $method(&mut self, other: &$u) {
$imp::$method(self, *other);
}
}
};
(impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => { (impl $imp:ident, $method:ident for $t:ty, $u:ty, #[$attr:meta]) => {
#[$attr] #[$attr]
impl $imp<&$u> for $t { impl $imp<&$u> for $t {

View file

@ -117,6 +117,7 @@
#![feature(const_maybe_uninit_as_ptr)] #![feature(const_maybe_uninit_as_ptr)]
#![feature(const_maybe_uninit_assume_init)] #![feature(const_maybe_uninit_assume_init)]
#![feature(const_num_from_num)] #![feature(const_num_from_num)]
#![feature(const_ops)]
#![feature(const_option)] #![feature(const_option)]
#![feature(const_pin)] #![feature(const_pin)]
#![feature(const_replace)] #![feature(const_replace)]

View file

@ -92,7 +92,8 @@ macro_rules! nonzero_integers {
} }
#[stable(feature = "nonzero_bitor", since = "1.45.0")] #[stable(feature = "nonzero_bitor", since = "1.45.0")]
impl BitOr for $Ty { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitOr for $Ty {
type Output = Self; type Output = Self;
#[inline] #[inline]
fn bitor(self, rhs: Self) -> Self::Output { fn bitor(self, rhs: Self) -> Self::Output {
@ -103,7 +104,8 @@ macro_rules! nonzero_integers {
} }
#[stable(feature = "nonzero_bitor", since = "1.45.0")] #[stable(feature = "nonzero_bitor", since = "1.45.0")]
impl BitOr<$Int> for $Ty { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitOr<$Int> for $Ty {
type Output = Self; type Output = Self;
#[inline] #[inline]
fn bitor(self, rhs: $Int) -> Self::Output { fn bitor(self, rhs: $Int) -> Self::Output {
@ -115,7 +117,8 @@ macro_rules! nonzero_integers {
} }
#[stable(feature = "nonzero_bitor", since = "1.45.0")] #[stable(feature = "nonzero_bitor", since = "1.45.0")]
impl BitOr<$Ty> for $Int { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitOr<$Ty> for $Int {
type Output = $Ty; type Output = $Ty;
#[inline] #[inline]
fn bitor(self, rhs: $Ty) -> Self::Output { fn bitor(self, rhs: $Ty) -> Self::Output {
@ -127,7 +130,8 @@ macro_rules! nonzero_integers {
} }
#[stable(feature = "nonzero_bitor", since = "1.45.0")] #[stable(feature = "nonzero_bitor", since = "1.45.0")]
impl BitOrAssign for $Ty { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitOrAssign for $Ty {
#[inline] #[inline]
fn bitor_assign(&mut self, rhs: Self) { fn bitor_assign(&mut self, rhs: Self) {
*self = *self | rhs; *self = *self | rhs;
@ -135,7 +139,8 @@ macro_rules! nonzero_integers {
} }
#[stable(feature = "nonzero_bitor", since = "1.45.0")] #[stable(feature = "nonzero_bitor", since = "1.45.0")]
impl BitOrAssign<$Int> for $Ty { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitOrAssign<$Int> for $Ty {
#[inline] #[inline]
fn bitor_assign(&mut self, rhs: $Int) { fn bitor_assign(&mut self, rhs: $Int) {
*self = *self | rhs; *self = *self | rhs;
@ -257,7 +262,8 @@ macro_rules! nonzero_integers_div {
( $( $Ty: ident($Int: ty); )+ ) => { ( $( $Ty: ident($Int: ty); )+ ) => {
$( $(
#[stable(feature = "nonzero_div", since = "1.51.0")] #[stable(feature = "nonzero_div", since = "1.51.0")]
impl Div<$Ty> for $Int { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Div<$Ty> for $Int {
type Output = $Int; type Output = $Int;
/// This operation rounds towards zero, /// This operation rounds towards zero,
/// truncating any fractional part of the exact result, and cannot panic. /// truncating any fractional part of the exact result, and cannot panic.
@ -270,7 +276,8 @@ macro_rules! nonzero_integers_div {
} }
#[stable(feature = "nonzero_div", since = "1.51.0")] #[stable(feature = "nonzero_div", since = "1.51.0")]
impl Rem<$Ty> for $Int { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Rem<$Ty> for $Int {
type Output = $Int; type Output = $Int;
/// This operation satisfies `n % d == n - (n / d) * d`, and cannot panic. /// This operation satisfies `n % d == n - (n / d) * d`, and cannot panic.
#[inline] #[inline]

View file

@ -87,7 +87,8 @@ impl<T: fmt::UpperHex> fmt::UpperHex for Wrapping<T> {
macro_rules! sh_impl_signed { macro_rules! sh_impl_signed {
($t:ident, $f:ident) => { ($t:ident, $f:ident) => {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Shl<$f> for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Shl<$f> for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -99,20 +100,22 @@ macro_rules! sh_impl_signed {
} }
} }
} }
forward_ref_binop! { impl Shl, shl for Wrapping<$t>, $f, forward_ref_binop! { impl const Shl, shl for Wrapping<$t>, $f,
#[stable(feature = "wrapping_ref_ops", since = "1.39.0")] } #[stable(feature = "wrapping_ref_ops", since = "1.39.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl ShlAssign<$f> for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const ShlAssign<$f> for Wrapping<$t> {
#[inline] #[inline]
fn shl_assign(&mut self, other: $f) { fn shl_assign(&mut self, other: $f) {
*self = *self << other; *self = *self << other;
} }
} }
forward_ref_op_assign! { impl ShlAssign, shl_assign for Wrapping<$t>, $f } forward_ref_op_assign! { impl const ShlAssign, shl_assign for Wrapping<$t>, $f }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Shr<$f> for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Shr<$f> for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -124,24 +127,26 @@ macro_rules! sh_impl_signed {
} }
} }
} }
forward_ref_binop! { impl Shr, shr for Wrapping<$t>, $f, forward_ref_binop! { impl const Shr, shr for Wrapping<$t>, $f,
#[stable(feature = "wrapping_ref_ops", since = "1.39.0")] } #[stable(feature = "wrapping_ref_ops", since = "1.39.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl ShrAssign<$f> for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const ShrAssign<$f> for Wrapping<$t> {
#[inline] #[inline]
fn shr_assign(&mut self, other: $f) { fn shr_assign(&mut self, other: $f) {
*self = *self >> other; *self = *self >> other;
} }
} }
forward_ref_op_assign! { impl ShrAssign, shr_assign for Wrapping<$t>, $f } forward_ref_op_assign! { impl const ShrAssign, shr_assign for Wrapping<$t>, $f }
}; };
} }
macro_rules! sh_impl_unsigned { macro_rules! sh_impl_unsigned {
($t:ident, $f:ident) => { ($t:ident, $f:ident) => {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Shl<$f> for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Shl<$f> for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -149,20 +154,22 @@ macro_rules! sh_impl_unsigned {
Wrapping(self.0.wrapping_shl((other & self::shift_max::$t as $f) as u32)) Wrapping(self.0.wrapping_shl((other & self::shift_max::$t as $f) as u32))
} }
} }
forward_ref_binop! { impl Shl, shl for Wrapping<$t>, $f, forward_ref_binop! { impl const Shl, shl for Wrapping<$t>, $f,
#[stable(feature = "wrapping_ref_ops", since = "1.39.0")] } #[stable(feature = "wrapping_ref_ops", since = "1.39.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl ShlAssign<$f> for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const ShlAssign<$f> for Wrapping<$t> {
#[inline] #[inline]
fn shl_assign(&mut self, other: $f) { fn shl_assign(&mut self, other: $f) {
*self = *self << other; *self = *self << other;
} }
} }
forward_ref_op_assign! { impl ShlAssign, shl_assign for Wrapping<$t>, $f } forward_ref_op_assign! { impl const ShlAssign, shl_assign for Wrapping<$t>, $f }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Shr<$f> for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Shr<$f> for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -170,17 +177,18 @@ macro_rules! sh_impl_unsigned {
Wrapping(self.0.wrapping_shr((other & self::shift_max::$t as $f) as u32)) Wrapping(self.0.wrapping_shr((other & self::shift_max::$t as $f) as u32))
} }
} }
forward_ref_binop! { impl Shr, shr for Wrapping<$t>, $f, forward_ref_binop! { impl const Shr, shr for Wrapping<$t>, $f,
#[stable(feature = "wrapping_ref_ops", since = "1.39.0")] } #[stable(feature = "wrapping_ref_ops", since = "1.39.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl ShrAssign<$f> for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const ShrAssign<$f> for Wrapping<$t> {
#[inline] #[inline]
fn shr_assign(&mut self, other: $f) { fn shr_assign(&mut self, other: $f) {
*self = *self >> other; *self = *self >> other;
} }
} }
forward_ref_op_assign! { impl ShrAssign, shr_assign for Wrapping<$t>, $f } forward_ref_op_assign! { impl const ShrAssign, shr_assign for Wrapping<$t>, $f }
}; };
} }
@ -209,7 +217,8 @@ sh_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
macro_rules! wrapping_impl { macro_rules! wrapping_impl {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Add for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Add for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -217,20 +226,22 @@ macro_rules! wrapping_impl {
Wrapping(self.0.wrapping_add(other.0)) Wrapping(self.0.wrapping_add(other.0))
} }
} }
forward_ref_binop! { impl Add, add for Wrapping<$t>, Wrapping<$t>, forward_ref_binop! { impl const Add, add for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] } #[stable(feature = "wrapping_ref", since = "1.14.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl AddAssign for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const AddAssign for Wrapping<$t> {
#[inline] #[inline]
fn add_assign(&mut self, other: Wrapping<$t>) { fn add_assign(&mut self, other: Wrapping<$t>) {
*self = *self + other; *self = *self + other;
} }
} }
forward_ref_op_assign! { impl AddAssign, add_assign for Wrapping<$t>, Wrapping<$t> } forward_ref_op_assign! { impl const AddAssign, add_assign for Wrapping<$t>, Wrapping<$t> }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Sub for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Sub for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -238,20 +249,22 @@ macro_rules! wrapping_impl {
Wrapping(self.0.wrapping_sub(other.0)) Wrapping(self.0.wrapping_sub(other.0))
} }
} }
forward_ref_binop! { impl Sub, sub for Wrapping<$t>, Wrapping<$t>, forward_ref_binop! { impl const Sub, sub for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] } #[stable(feature = "wrapping_ref", since = "1.14.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl SubAssign for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const SubAssign for Wrapping<$t> {
#[inline] #[inline]
fn sub_assign(&mut self, other: Wrapping<$t>) { fn sub_assign(&mut self, other: Wrapping<$t>) {
*self = *self - other; *self = *self - other;
} }
} }
forward_ref_op_assign! { impl SubAssign, sub_assign for Wrapping<$t>, Wrapping<$t> } forward_ref_op_assign! { impl const SubAssign, sub_assign for Wrapping<$t>, Wrapping<$t> }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Mul for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Mul for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -263,16 +276,18 @@ macro_rules! wrapping_impl {
#[stable(feature = "wrapping_ref", since = "1.14.0")] } #[stable(feature = "wrapping_ref", since = "1.14.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl MulAssign for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const MulAssign for Wrapping<$t> {
#[inline] #[inline]
fn mul_assign(&mut self, other: Wrapping<$t>) { fn mul_assign(&mut self, other: Wrapping<$t>) {
*self = *self * other; *self = *self * other;
} }
} }
forward_ref_op_assign! { impl MulAssign, mul_assign for Wrapping<$t>, Wrapping<$t> } forward_ref_op_assign! { impl const MulAssign, mul_assign for Wrapping<$t>, Wrapping<$t> }
#[stable(feature = "wrapping_div", since = "1.3.0")] #[stable(feature = "wrapping_div", since = "1.3.0")]
impl Div for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Div for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -280,20 +295,22 @@ macro_rules! wrapping_impl {
Wrapping(self.0.wrapping_div(other.0)) Wrapping(self.0.wrapping_div(other.0))
} }
} }
forward_ref_binop! { impl Div, div for Wrapping<$t>, Wrapping<$t>, forward_ref_binop! { impl const Div, div for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] } #[stable(feature = "wrapping_ref", since = "1.14.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl DivAssign for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const DivAssign for Wrapping<$t> {
#[inline] #[inline]
fn div_assign(&mut self, other: Wrapping<$t>) { fn div_assign(&mut self, other: Wrapping<$t>) {
*self = *self / other; *self = *self / other;
} }
} }
forward_ref_op_assign! { impl DivAssign, div_assign for Wrapping<$t>, Wrapping<$t> } forward_ref_op_assign! { impl const DivAssign, div_assign for Wrapping<$t>, Wrapping<$t> }
#[stable(feature = "wrapping_impls", since = "1.7.0")] #[stable(feature = "wrapping_impls", since = "1.7.0")]
impl Rem for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Rem for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -301,20 +318,22 @@ macro_rules! wrapping_impl {
Wrapping(self.0.wrapping_rem(other.0)) Wrapping(self.0.wrapping_rem(other.0))
} }
} }
forward_ref_binop! { impl Rem, rem for Wrapping<$t>, Wrapping<$t>, forward_ref_binop! { impl const Rem, rem for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] } #[stable(feature = "wrapping_ref", since = "1.14.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl RemAssign for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const RemAssign for Wrapping<$t> {
#[inline] #[inline]
fn rem_assign(&mut self, other: Wrapping<$t>) { fn rem_assign(&mut self, other: Wrapping<$t>) {
*self = *self % other; *self = *self % other;
} }
} }
forward_ref_op_assign! { impl RemAssign, rem_assign for Wrapping<$t>, Wrapping<$t> } forward_ref_op_assign! { impl const RemAssign, rem_assign for Wrapping<$t>, Wrapping<$t> }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Not for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Not for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -322,11 +341,12 @@ macro_rules! wrapping_impl {
Wrapping(!self.0) Wrapping(!self.0)
} }
} }
forward_ref_unop! { impl Not, not for Wrapping<$t>, forward_ref_unop! { impl const Not, not for Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] } #[stable(feature = "wrapping_ref", since = "1.14.0")] }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl BitXor for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitXor for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -334,20 +354,22 @@ macro_rules! wrapping_impl {
Wrapping(self.0 ^ other.0) Wrapping(self.0 ^ other.0)
} }
} }
forward_ref_binop! { impl BitXor, bitxor for Wrapping<$t>, Wrapping<$t>, forward_ref_binop! { impl const BitXor, bitxor for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] } #[stable(feature = "wrapping_ref", since = "1.14.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitXorAssign for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitXorAssign for Wrapping<$t> {
#[inline] #[inline]
fn bitxor_assign(&mut self, other: Wrapping<$t>) { fn bitxor_assign(&mut self, other: Wrapping<$t>) {
*self = *self ^ other; *self = *self ^ other;
} }
} }
forward_ref_op_assign! { impl BitXorAssign, bitxor_assign for Wrapping<$t>, Wrapping<$t> } forward_ref_op_assign! { impl const BitXorAssign, bitxor_assign for Wrapping<$t>, Wrapping<$t> }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl BitOr for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitOr for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -355,20 +377,22 @@ macro_rules! wrapping_impl {
Wrapping(self.0 | other.0) Wrapping(self.0 | other.0)
} }
} }
forward_ref_binop! { impl BitOr, bitor for Wrapping<$t>, Wrapping<$t>, forward_ref_binop! { impl const BitOr, bitor for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] } #[stable(feature = "wrapping_ref", since = "1.14.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitOrAssign for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitOrAssign for Wrapping<$t> {
#[inline] #[inline]
fn bitor_assign(&mut self, other: Wrapping<$t>) { fn bitor_assign(&mut self, other: Wrapping<$t>) {
*self = *self | other; *self = *self | other;
} }
} }
forward_ref_op_assign! { impl BitOrAssign, bitor_assign for Wrapping<$t>, Wrapping<$t> } forward_ref_op_assign! { impl const BitOrAssign, bitor_assign for Wrapping<$t>, Wrapping<$t> }
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl BitAnd for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitAnd for Wrapping<$t> {
type Output = Wrapping<$t>; type Output = Wrapping<$t>;
#[inline] #[inline]
@ -376,27 +400,29 @@ macro_rules! wrapping_impl {
Wrapping(self.0 & other.0) Wrapping(self.0 & other.0)
} }
} }
forward_ref_binop! { impl BitAnd, bitand for Wrapping<$t>, Wrapping<$t>, forward_ref_binop! { impl const BitAnd, bitand for Wrapping<$t>, Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] } #[stable(feature = "wrapping_ref", since = "1.14.0")] }
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitAndAssign for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitAndAssign for Wrapping<$t> {
#[inline] #[inline]
fn bitand_assign(&mut self, other: Wrapping<$t>) { fn bitand_assign(&mut self, other: Wrapping<$t>) {
*self = *self & other; *self = *self & other;
} }
} }
forward_ref_op_assign! { impl BitAndAssign, bitand_assign for Wrapping<$t>, Wrapping<$t> } forward_ref_op_assign! { impl const BitAndAssign, bitand_assign for Wrapping<$t>, Wrapping<$t> }
#[stable(feature = "wrapping_neg", since = "1.10.0")] #[stable(feature = "wrapping_neg", since = "1.10.0")]
impl Neg for Wrapping<$t> { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Neg for Wrapping<$t> {
type Output = Self; type Output = Self;
#[inline] #[inline]
fn neg(self) -> Self { fn neg(self) -> Self {
Wrapping(0) - self Wrapping(0) - self
} }
} }
forward_ref_unop! { impl Neg, neg for Wrapping<$t>, forward_ref_unop! { impl const Neg, neg for Wrapping<$t>,
#[stable(feature = "wrapping_ref", since = "1.14.0")] } #[stable(feature = "wrapping_ref", since = "1.14.0")] }
)*) )*)

View file

@ -92,7 +92,8 @@ pub trait Add<Rhs = Self> {
macro_rules! add_impl { macro_rules! add_impl {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Add for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Add for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
@ -100,7 +101,7 @@ macro_rules! add_impl {
fn add(self, other: $t) -> $t { self + other } fn add(self, other: $t) -> $t { self + other }
} }
forward_ref_binop! { impl Add, add for $t, $t } forward_ref_binop! { impl const Add, add for $t, $t }
)*) )*)
} }
@ -198,7 +199,8 @@ pub trait Sub<Rhs = Self> {
macro_rules! sub_impl { macro_rules! sub_impl {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Sub for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Sub for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
@ -206,7 +208,7 @@ macro_rules! sub_impl {
fn sub(self, other: $t) -> $t { self - other } fn sub(self, other: $t) -> $t { self - other }
} }
forward_ref_binop! { impl Sub, sub for $t, $t } forward_ref_binop! { impl const Sub, sub for $t, $t }
)*) )*)
} }
@ -326,7 +328,8 @@ pub trait Mul<Rhs = Self> {
macro_rules! mul_impl { macro_rules! mul_impl {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Mul for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Mul for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
@ -334,7 +337,7 @@ macro_rules! mul_impl {
fn mul(self, other: $t) -> $t { self * other } fn mul(self, other: $t) -> $t { self * other }
} }
forward_ref_binop! { impl Mul, mul for $t, $t } forward_ref_binop! { impl const Mul, mul for $t, $t }
)*) )*)
} }
@ -464,14 +467,15 @@ macro_rules! div_impl_integer {
/// ///
#[doc = $panic] #[doc = $panic]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Div for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Div for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
fn div(self, other: $t) -> $t { self / other } fn div(self, other: $t) -> $t { self / other }
} }
forward_ref_binop! { impl Div, div for $t, $t } forward_ref_binop! { impl const Div, div for $t, $t }
)*)*) )*)*)
} }
@ -483,14 +487,15 @@ div_impl_integer! {
macro_rules! div_impl_float { macro_rules! div_impl_float {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Div for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Div for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
fn div(self, other: $t) -> $t { self / other } fn div(self, other: $t) -> $t { self / other }
} }
forward_ref_binop! { impl Div, div for $t, $t } forward_ref_binop! { impl const Div, div for $t, $t }
)*) )*)
} }
@ -564,14 +569,15 @@ macro_rules! rem_impl_integer {
/// ///
#[doc = $panic] #[doc = $panic]
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Rem for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Rem for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
fn rem(self, other: $t) -> $t { self % other } fn rem(self, other: $t) -> $t { self % other }
} }
forward_ref_binop! { impl Rem, rem for $t, $t } forward_ref_binop! { impl const Rem, rem for $t, $t }
)*)*) )*)*)
} }
@ -598,14 +604,15 @@ macro_rules! rem_impl_float {
/// assert_eq!(x % y, remainder); /// assert_eq!(x % y, remainder);
/// ``` /// ```
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Rem for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Rem for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
fn rem(self, other: $t) -> $t { self % other } fn rem(self, other: $t) -> $t { self % other }
} }
forward_ref_binop! { impl Rem, rem for $t, $t } forward_ref_binop! { impl const Rem, rem for $t, $t }
)*) )*)
} }
@ -671,7 +678,8 @@ pub trait Neg {
macro_rules! neg_impl { macro_rules! neg_impl {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Neg for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Neg for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
@ -679,7 +687,7 @@ macro_rules! neg_impl {
fn neg(self) -> $t { -self } fn neg(self) -> $t { -self }
} }
forward_ref_unop! { impl Neg, neg for $t } forward_ref_unop! { impl const Neg, neg for $t }
)*) )*)
} }
@ -739,13 +747,14 @@ pub trait AddAssign<Rhs = Self> {
macro_rules! add_assign_impl { macro_rules! add_assign_impl {
($($t:ty)+) => ($( ($($t:ty)+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl AddAssign for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const AddAssign for $t {
#[inline] #[inline]
#[rustc_inherit_overflow_checks] #[rustc_inherit_overflow_checks]
fn add_assign(&mut self, other: $t) { *self += other } fn add_assign(&mut self, other: $t) { *self += other }
} }
forward_ref_op_assign! { impl AddAssign, add_assign for $t, $t } forward_ref_op_assign! { impl const AddAssign, add_assign for $t, $t }
)+) )+)
} }
@ -805,13 +814,14 @@ pub trait SubAssign<Rhs = Self> {
macro_rules! sub_assign_impl { macro_rules! sub_assign_impl {
($($t:ty)+) => ($( ($($t:ty)+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl SubAssign for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const SubAssign for $t {
#[inline] #[inline]
#[rustc_inherit_overflow_checks] #[rustc_inherit_overflow_checks]
fn sub_assign(&mut self, other: $t) { *self -= other } fn sub_assign(&mut self, other: $t) { *self -= other }
} }
forward_ref_op_assign! { impl SubAssign, sub_assign for $t, $t } forward_ref_op_assign! { impl const SubAssign, sub_assign for $t, $t }
)+) )+)
} }
@ -862,13 +872,14 @@ pub trait MulAssign<Rhs = Self> {
macro_rules! mul_assign_impl { macro_rules! mul_assign_impl {
($($t:ty)+) => ($( ($($t:ty)+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl MulAssign for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const MulAssign for $t {
#[inline] #[inline]
#[rustc_inherit_overflow_checks] #[rustc_inherit_overflow_checks]
fn mul_assign(&mut self, other: $t) { *self *= other } fn mul_assign(&mut self, other: $t) { *self *= other }
} }
forward_ref_op_assign! { impl MulAssign, mul_assign for $t, $t } forward_ref_op_assign! { impl const MulAssign, mul_assign for $t, $t }
)+) )+)
} }
@ -919,12 +930,13 @@ pub trait DivAssign<Rhs = Self> {
macro_rules! div_assign_impl { macro_rules! div_assign_impl {
($($t:ty)+) => ($( ($($t:ty)+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl DivAssign for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const DivAssign for $t {
#[inline] #[inline]
fn div_assign(&mut self, other: $t) { *self /= other } fn div_assign(&mut self, other: $t) { *self /= other }
} }
forward_ref_op_assign! { impl DivAssign, div_assign for $t, $t } forward_ref_op_assign! { impl const DivAssign, div_assign for $t, $t }
)+) )+)
} }
@ -979,12 +991,13 @@ pub trait RemAssign<Rhs = Self> {
macro_rules! rem_assign_impl { macro_rules! rem_assign_impl {
($($t:ty)+) => ($( ($($t:ty)+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl RemAssign for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const RemAssign for $t {
#[inline] #[inline]
fn rem_assign(&mut self, other: $t) { *self %= other } fn rem_assign(&mut self, other: $t) { *self %= other }
} }
forward_ref_op_assign! { impl RemAssign, rem_assign for $t, $t } forward_ref_op_assign! { impl const RemAssign, rem_assign for $t, $t }
)+) )+)
} }

View file

@ -54,14 +54,15 @@ pub trait Not {
macro_rules! not_impl { macro_rules! not_impl {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Not for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Not for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
fn not(self) -> $t { !self } fn not(self) -> $t { !self }
} }
forward_ref_unop! { impl Not, not for $t } forward_ref_unop! { impl const Not, not for $t }
)*) )*)
} }
@ -154,14 +155,15 @@ pub trait BitAnd<Rhs = Self> {
macro_rules! bitand_impl { macro_rules! bitand_impl {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl BitAnd for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitAnd for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
fn bitand(self, rhs: $t) -> $t { self & rhs } fn bitand(self, rhs: $t) -> $t { self & rhs }
} }
forward_ref_binop! { impl BitAnd, bitand for $t, $t } forward_ref_binop! { impl const BitAnd, bitand for $t, $t }
)*) )*)
} }
@ -254,14 +256,15 @@ pub trait BitOr<Rhs = Self> {
macro_rules! bitor_impl { macro_rules! bitor_impl {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl BitOr for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitOr for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
fn bitor(self, rhs: $t) -> $t { self | rhs } fn bitor(self, rhs: $t) -> $t { self | rhs }
} }
forward_ref_binop! { impl BitOr, bitor for $t, $t } forward_ref_binop! { impl const BitOr, bitor for $t, $t }
)*) )*)
} }
@ -354,14 +357,15 @@ pub trait BitXor<Rhs = Self> {
macro_rules! bitxor_impl { macro_rules! bitxor_impl {
($($t:ty)*) => ($( ($($t:ty)*) => ($(
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl BitXor for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitXor for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
fn bitxor(self, other: $t) -> $t { self ^ other } fn bitxor(self, other: $t) -> $t { self ^ other }
} }
forward_ref_binop! { impl BitXor, bitxor for $t, $t } forward_ref_binop! { impl const BitXor, bitxor for $t, $t }
)*) )*)
} }
@ -451,7 +455,8 @@ pub trait Shl<Rhs = Self> {
macro_rules! shl_impl { macro_rules! shl_impl {
($t:ty, $f:ty) => { ($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Shl<$f> for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Shl<$f> for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
@ -461,7 +466,7 @@ macro_rules! shl_impl {
} }
} }
forward_ref_binop! { impl Shl, shl for $t, $f } forward_ref_binop! { impl const Shl, shl for $t, $f }
}; };
} }
@ -569,7 +574,8 @@ pub trait Shr<Rhs = Self> {
macro_rules! shr_impl { macro_rules! shr_impl {
($t:ty, $f:ty) => { ($t:ty, $f:ty) => {
#[stable(feature = "rust1", since = "1.0.0")] #[stable(feature = "rust1", since = "1.0.0")]
impl Shr<$f> for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const Shr<$f> for $t {
type Output = $t; type Output = $t;
#[inline] #[inline]
@ -579,7 +585,7 @@ macro_rules! shr_impl {
} }
} }
forward_ref_binop! { impl Shr, shr for $t, $f } forward_ref_binop! { impl const Shr, shr for $t, $f }
}; };
} }
@ -704,12 +710,13 @@ pub trait BitAndAssign<Rhs = Self> {
macro_rules! bitand_assign_impl { macro_rules! bitand_assign_impl {
($($t:ty)+) => ($( ($($t:ty)+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitAndAssign for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitAndAssign for $t {
#[inline] #[inline]
fn bitand_assign(&mut self, other: $t) { *self &= other } fn bitand_assign(&mut self, other: $t) { *self &= other }
} }
forward_ref_op_assign! { impl BitAndAssign, bitand_assign for $t, $t } forward_ref_op_assign! { impl const BitAndAssign, bitand_assign for $t, $t }
)+) )+)
} }
@ -775,12 +782,13 @@ pub trait BitOrAssign<Rhs = Self> {
macro_rules! bitor_assign_impl { macro_rules! bitor_assign_impl {
($($t:ty)+) => ($( ($($t:ty)+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitOrAssign for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitOrAssign for $t {
#[inline] #[inline]
fn bitor_assign(&mut self, other: $t) { *self |= other } fn bitor_assign(&mut self, other: $t) { *self |= other }
} }
forward_ref_op_assign! { impl BitOrAssign, bitor_assign for $t, $t } forward_ref_op_assign! { impl const BitOrAssign, bitor_assign for $t, $t }
)+) )+)
} }
@ -846,12 +854,13 @@ pub trait BitXorAssign<Rhs = Self> {
macro_rules! bitxor_assign_impl { macro_rules! bitxor_assign_impl {
($($t:ty)+) => ($( ($($t:ty)+) => ($(
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl BitXorAssign for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const BitXorAssign for $t {
#[inline] #[inline]
fn bitxor_assign(&mut self, other: $t) { *self ^= other } fn bitxor_assign(&mut self, other: $t) { *self ^= other }
} }
forward_ref_op_assign! { impl BitXorAssign, bitxor_assign for $t, $t } forward_ref_op_assign! { impl const BitXorAssign, bitxor_assign for $t, $t }
)+) )+)
} }
@ -907,7 +916,8 @@ pub trait ShlAssign<Rhs = Self> {
macro_rules! shl_assign_impl { macro_rules! shl_assign_impl {
($t:ty, $f:ty) => { ($t:ty, $f:ty) => {
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl ShlAssign<$f> for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const ShlAssign<$f> for $t {
#[inline] #[inline]
#[rustc_inherit_overflow_checks] #[rustc_inherit_overflow_checks]
fn shl_assign(&mut self, other: $f) { fn shl_assign(&mut self, other: $f) {
@ -915,7 +925,7 @@ macro_rules! shl_assign_impl {
} }
} }
forward_ref_op_assign! { impl ShlAssign, shl_assign for $t, $f } forward_ref_op_assign! { impl const ShlAssign, shl_assign for $t, $f }
}; };
} }
@ -989,7 +999,8 @@ pub trait ShrAssign<Rhs = Self> {
macro_rules! shr_assign_impl { macro_rules! shr_assign_impl {
($t:ty, $f:ty) => { ($t:ty, $f:ty) => {
#[stable(feature = "op_assign_traits", since = "1.8.0")] #[stable(feature = "op_assign_traits", since = "1.8.0")]
impl ShrAssign<$f> for $t { #[rustc_const_unstable(feature = "const_ops", issue = "90080")]
impl const ShrAssign<$f> for $t {
#[inline] #[inline]
#[rustc_inherit_overflow_checks] #[rustc_inherit_overflow_checks]
fn shr_assign(&mut self, other: $f) { fn shr_assign(&mut self, other: $f) {
@ -997,7 +1008,7 @@ macro_rules! shr_assign_impl {
} }
} }
forward_ref_op_assign! { impl ShrAssign, shr_assign for $t, $f } forward_ref_op_assign! { impl const ShrAssign, shr_assign for $t, $f }
}; };
} }