Skip to content

Commit be65e03

Browse files
committed
Add const_traits
1 parent 81b1810 commit be65e03

File tree

6 files changed

+11
-0
lines changed

6 files changed

+11
-0
lines changed

library/core/src/borrow.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,7 @@
154154
/// [`String`]: ../../std/string/struct.String.html
155155
#[stable(feature = "rust1", since = "1.0.0")]
156156
#[rustc_diagnostic_item = "Borrow"]
157+
#[const_trait]
157158
pub trait Borrow<Borrowed: ?Sized> {
158159
/// Immutably borrows from an owned value.
159160
///
@@ -184,6 +185,7 @@ pub trait Borrow<Borrowed: ?Sized> {
184185
/// an underlying type by providing a mutable reference. See [`Borrow<T>`]
185186
/// for more information on borrowing as another type.
186187
#[stable(feature = "rust1", since = "1.0.0")]
188+
#[const_trait]
187189
pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> {
188190
/// Mutably borrows from an owned value.
189191
///

library/core/src/iter/traits/collect.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,7 @@ pub trait FromIterator<A>: Sized {
228228
#[rustc_diagnostic_item = "IntoIterator"]
229229
#[rustc_skip_array_during_method_dispatch]
230230
#[stable(feature = "rust1", since = "1.0.0")]
231+
#[const_trait]
231232
pub trait IntoIterator {
232233
/// The type of the elements being iterated over.
233234
#[stable(feature = "rust1", since = "1.0.0")]

library/core/src/ops/arith.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,7 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
938938
)]
939939
#[doc(alias = "/")]
940940
#[doc(alias = "/=")]
941+
#[const_trait]
941942
pub trait DivAssign<Rhs = Self> {
942943
/// Performs the `/=` operation.
943944
///
@@ -999,6 +1000,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
9991000
)]
10001001
#[doc(alias = "%")]
10011002
#[doc(alias = "%=")]
1003+
#[const_trait]
10021004
pub trait RemAssign<Rhs = Self> {
10031005
/// Performs the `%=` operation.
10041006
///

library/core/src/ops/bit.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#[lang = "not"]
3232
#[stable(feature = "rust1", since = "1.0.0")]
3333
#[doc(alias = "!")]
34+
#[const_trait]
3435
pub trait Not {
3536
/// The resulting type after applying the `!` operator.
3637
#[stable(feature = "rust1", since = "1.0.0")]
@@ -906,6 +907,7 @@ bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
906907
message = "no implementation for `{Self} <<= {Rhs}`",
907908
label = "no implementation for `{Self} <<= {Rhs}`"
908909
)]
910+
#[const_trait]
909911
pub trait ShlAssign<Rhs = Self> {
910912
/// Performs the `<<=` operation.
911913
///
@@ -989,6 +991,7 @@ shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
989991
message = "no implementation for `{Self} >>= {Rhs}`",
990992
label = "no implementation for `{Self} >>= {Rhs}`"
991993
)]
994+
#[const_trait]
992995
pub trait ShrAssign<Rhs = Self> {
993996
/// Performs the `>>=` operation.
994997
///

library/core/src/ops/deref.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@
6161
#[doc(alias = "&*")]
6262
#[stable(feature = "rust1", since = "1.0.0")]
6363
#[rustc_diagnostic_item = "Deref"]
64+
#[const_trait]
6465
pub trait Deref {
6566
/// The resulting type after dereferencing.
6667
#[stable(feature = "rust1", since = "1.0.0")]

library/core/src/ops/try_trait.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ use crate::ops::ControlFlow;
128128
)]
129129
#[doc(alias = "?")]
130130
#[lang = "Try"]
131+
#[const_trait]
131132
pub trait Try: FromResidual {
132133
/// The type of the value produced by `?` when *not* short-circuiting.
133134
#[unstable(feature = "try_trait_v2", issue = "84277")]
@@ -384,6 +385,7 @@ pub trait Try: FromResidual {
384385
))]
385386
#[rustc_diagnostic_item = "FromResidual"]
386387
#[unstable(feature = "try_trait_v2", issue = "84277")]
388+
#[const_trait]
387389
pub trait FromResidual<R = <Self as Try>::Residual> {
388390
/// Constructs the type from a compatible `Residual` type.
389391
///

0 commit comments

Comments
 (0)