diff options
| author | Deadbeef <ent3rm4n@gmail.com> | 2022-08-09 17:39:09 +0000 |
|---|---|---|
| committer | Deadbeef <ent3rm4n@gmail.com> | 2022-09-16 11:48:42 +0800 |
| commit | be65e03676607dabac87cb4771692e5fc0fb6ad7 (patch) | |
| tree | b199375d8777ae489bda50d1fcbf0d5b58ee5685 | |
| parent | 81b1810cd7b5f1cb74d498f20fa0ef5887420d33 (diff) | |
| download | rust-be65e03676607dabac87cb4771692e5fc0fb6ad7.tar.gz rust-be65e03676607dabac87cb4771692e5fc0fb6ad7.zip | |
Add `const_trait`s
| -rw-r--r-- | library/core/src/borrow.rs | 2 | ||||
| -rw-r--r-- | library/core/src/iter/traits/collect.rs | 1 | ||||
| -rw-r--r-- | library/core/src/ops/arith.rs | 2 | ||||
| -rw-r--r-- | library/core/src/ops/bit.rs | 3 | ||||
| -rw-r--r-- | library/core/src/ops/deref.rs | 1 | ||||
| -rw-r--r-- | library/core/src/ops/try_trait.rs | 2 |
6 files changed, 11 insertions, 0 deletions
diff --git a/library/core/src/borrow.rs b/library/core/src/borrow.rs index 8378611eb18..fdd56cb4eaa 100644 --- a/library/core/src/borrow.rs +++ b/library/core/src/borrow.rs @@ -154,6 +154,7 @@ /// [`String`]: ../../std/string/struct.String.html #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "Borrow"] +#[const_trait] pub trait Borrow<Borrowed: ?Sized> { /// Immutably borrows from an owned value. /// @@ -184,6 +185,7 @@ pub trait Borrow<Borrowed: ?Sized> { /// an underlying type by providing a mutable reference. See [`Borrow<T>`] /// for more information on borrowing as another type. #[stable(feature = "rust1", since = "1.0.0")] +#[const_trait] pub trait BorrowMut<Borrowed: ?Sized>: Borrow<Borrowed> { /// Mutably borrows from an owned value. /// diff --git a/library/core/src/iter/traits/collect.rs b/library/core/src/iter/traits/collect.rs index 12ca508bed2..e598a54b4f1 100644 --- a/library/core/src/iter/traits/collect.rs +++ b/library/core/src/iter/traits/collect.rs @@ -228,6 +228,7 @@ pub trait FromIterator<A>: Sized { #[rustc_diagnostic_item = "IntoIterator"] #[rustc_skip_array_during_method_dispatch] #[stable(feature = "rust1", since = "1.0.0")] +#[const_trait] pub trait IntoIterator { /// The type of the elements being iterated over. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/ops/arith.rs b/library/core/src/ops/arith.rs index e367be8c167..20bd9590422 100644 --- a/library/core/src/ops/arith.rs +++ b/library/core/src/ops/arith.rs @@ -938,6 +938,7 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } )] #[doc(alias = "/")] #[doc(alias = "/=")] +#[const_trait] pub trait DivAssign<Rhs = Self> { /// Performs the `/=` operation. /// @@ -999,6 +1000,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 } )] #[doc(alias = "%")] #[doc(alias = "%=")] +#[const_trait] pub trait RemAssign<Rhs = Self> { /// Performs the `%=` operation. /// diff --git a/library/core/src/ops/bit.rs b/library/core/src/ops/bit.rs index 7c664226fc2..ec8f12cd161 100644 --- a/library/core/src/ops/bit.rs +++ b/library/core/src/ops/bit.rs @@ -31,6 +31,7 @@ #[lang = "not"] #[stable(feature = "rust1", since = "1.0.0")] #[doc(alias = "!")] +#[const_trait] pub trait Not { /// The resulting type after applying the `!` operator. #[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 } message = "no implementation for `{Self} <<= {Rhs}`", label = "no implementation for `{Self} <<= {Rhs}`" )] +#[const_trait] pub trait ShlAssign<Rhs = Self> { /// Performs the `<<=` operation. /// @@ -989,6 +991,7 @@ shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize } message = "no implementation for `{Self} >>= {Rhs}`", label = "no implementation for `{Self} >>= {Rhs}`" )] +#[const_trait] pub trait ShrAssign<Rhs = Self> { /// Performs the `>>=` operation. /// diff --git a/library/core/src/ops/deref.rs b/library/core/src/ops/deref.rs index d68932402a4..1f2df351e96 100644 --- a/library/core/src/ops/deref.rs +++ b/library/core/src/ops/deref.rs @@ -61,6 +61,7 @@ #[doc(alias = "&*")] #[stable(feature = "rust1", since = "1.0.0")] #[rustc_diagnostic_item = "Deref"] +#[const_trait] pub trait Deref { /// The resulting type after dereferencing. #[stable(feature = "rust1", since = "1.0.0")] diff --git a/library/core/src/ops/try_trait.rs b/library/core/src/ops/try_trait.rs index 10f04134409..dfde0b37acf 100644 --- a/library/core/src/ops/try_trait.rs +++ b/library/core/src/ops/try_trait.rs @@ -128,6 +128,7 @@ use crate::ops::ControlFlow; )] #[doc(alias = "?")] #[lang = "Try"] +#[const_trait] pub trait Try: FromResidual { /// The type of the value produced by `?` when *not* short-circuiting. #[unstable(feature = "try_trait_v2", issue = "84277")] @@ -384,6 +385,7 @@ pub trait Try: FromResidual { ))] #[rustc_diagnostic_item = "FromResidual"] #[unstable(feature = "try_trait_v2", issue = "84277")] +#[const_trait] pub trait FromResidual<R = <Self as Try>::Residual> { /// Constructs the type from a compatible `Residual` type. /// |
