mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-22 23:04:33 +00:00
Add more const_trait
annotations
This commit is contained in:
parent
be65e03676
commit
4b539b04a6
@ -155,6 +155,7 @@ pub const fn identity<T>(x: T) -> T {
|
||||
/// ```
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[cfg_attr(not(test), rustc_diagnostic_item = "AsRef")]
|
||||
#[const_trait]
|
||||
pub trait AsRef<T: ?Sized> {
|
||||
/// Converts this type into a shared reference of the (usually inferred) input type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -197,6 +198,7 @@ pub trait AsRef<T: ?Sized> {
|
||||
/// [`Box<T>`]: ../../std/boxed/struct.Box.html
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[cfg_attr(not(test), rustc_diagnostic_item = "AsMut")]
|
||||
#[const_trait]
|
||||
pub trait AsMut<T: ?Sized> {
|
||||
/// Converts this type into a mutable reference of the (usually inferred) input type.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -273,6 +275,7 @@ pub trait AsMut<T: ?Sized> {
|
||||
/// [`Vec`]: ../../std/vec/struct.Vec.html
|
||||
#[rustc_diagnostic_item = "Into"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[const_trait]
|
||||
pub trait Into<T>: Sized {
|
||||
/// Converts this type into the (usually inferred) input type.
|
||||
#[must_use]
|
||||
@ -393,6 +396,7 @@ pub trait From<T>: Sized {
|
||||
/// [`Into`], see there for details.
|
||||
#[rustc_diagnostic_item = "TryInto"]
|
||||
#[stable(feature = "try_from", since = "1.34.0")]
|
||||
#[const_trait]
|
||||
pub trait TryInto<T>: Sized {
|
||||
/// The type returned in the event of a conversion error.
|
||||
#[stable(feature = "try_from", since = "1.34.0")]
|
||||
@ -469,6 +473,7 @@ pub trait TryInto<T>: Sized {
|
||||
/// [`try_from`]: TryFrom::try_from
|
||||
#[rustc_diagnostic_item = "TryFrom"]
|
||||
#[stable(feature = "try_from", since = "1.34.0")]
|
||||
#[const_trait]
|
||||
pub trait TryFrom<T>: Sized {
|
||||
/// The type returned in the event of a conversion error.
|
||||
#[stable(feature = "try_from", since = "1.34.0")]
|
||||
|
@ -97,6 +97,7 @@
|
||||
)
|
||||
)]
|
||||
#[doc(alias = "+")]
|
||||
#[const_trait]
|
||||
pub trait Add<Rhs = Self> {
|
||||
/// The resulting type after applying the `+` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -204,6 +205,7 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
label = "no implementation for `{Self} - {Rhs}`"
|
||||
)]
|
||||
#[doc(alias = "-")]
|
||||
#[const_trait]
|
||||
pub trait Sub<Rhs = Self> {
|
||||
/// The resulting type after applying the `-` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -333,6 +335,7 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
label = "no implementation for `{Self} * {Rhs}`"
|
||||
)]
|
||||
#[doc(alias = "*")]
|
||||
#[const_trait]
|
||||
pub trait Mul<Rhs = Self> {
|
||||
/// The resulting type after applying the `*` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -466,6 +469,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
label = "no implementation for `{Self} / {Rhs}`"
|
||||
)]
|
||||
#[doc(alias = "/")]
|
||||
#[const_trait]
|
||||
pub trait Div<Rhs = Self> {
|
||||
/// The resulting type after applying the `/` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -568,6 +572,7 @@ div_impl_float! { f32 f64 }
|
||||
label = "no implementation for `{Self} % {Rhs}`"
|
||||
)]
|
||||
#[doc(alias = "%")]
|
||||
#[const_trait]
|
||||
pub trait Rem<Rhs = Self> {
|
||||
/// The resulting type after applying the `%` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -682,6 +687,7 @@ rem_impl_float! { f32 f64 }
|
||||
#[lang = "neg"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[doc(alias = "-")]
|
||||
#[const_trait]
|
||||
pub trait Neg {
|
||||
/// The resulting type after applying the `-` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -755,6 +761,7 @@ neg_impl! { isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
)]
|
||||
#[doc(alias = "+")]
|
||||
#[doc(alias = "+=")]
|
||||
#[const_trait]
|
||||
pub trait AddAssign<Rhs = Self> {
|
||||
/// Performs the `+=` operation.
|
||||
///
|
||||
@ -822,6 +829,7 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
)]
|
||||
#[doc(alias = "-")]
|
||||
#[doc(alias = "-=")]
|
||||
#[const_trait]
|
||||
pub trait SubAssign<Rhs = Self> {
|
||||
/// Performs the `-=` operation.
|
||||
///
|
||||
@ -880,6 +888,7 @@ sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f32 f64 }
|
||||
)]
|
||||
#[doc(alias = "*")]
|
||||
#[doc(alias = "*=")]
|
||||
#[const_trait]
|
||||
pub trait MulAssign<Rhs = Self> {
|
||||
/// Performs the `*=` operation.
|
||||
///
|
||||
|
@ -144,6 +144,7 @@ impl const Not for ! {
|
||||
message = "no implementation for `{Self} & {Rhs}`",
|
||||
label = "no implementation for `{Self} & {Rhs}`"
|
||||
)]
|
||||
#[const_trait]
|
||||
pub trait BitAnd<Rhs = Self> {
|
||||
/// The resulting type after applying the `&` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -245,6 +246,7 @@ bitand_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 BitOr<Rhs = Self> {
|
||||
/// The resulting type after applying the `|` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -346,6 +348,7 @@ bitor_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 BitXor<Rhs = Self> {
|
||||
/// The resulting type after applying the `^` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -446,6 +449,7 @@ bitxor_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 Shl<Rhs = Self> {
|
||||
/// The resulting type after applying the `<<` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -565,6 +569,7 @@ shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 isize i128 }
|
||||
message = "no implementation for `{Self} >> {Rhs}`",
|
||||
label = "no implementation for `{Self} >> {Rhs}`"
|
||||
)]
|
||||
#[const_trait]
|
||||
pub trait Shr<Rhs = Self> {
|
||||
/// The resulting type after applying the `>>` operator.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -693,6 +698,7 @@ shr_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 BitAndAssign<Rhs = Self> {
|
||||
/// Performs the `&=` operation.
|
||||
///
|
||||
@ -765,6 +771,7 @@ bitand_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 BitOrAssign<Rhs = Self> {
|
||||
/// Performs the `|=` operation.
|
||||
///
|
||||
@ -837,6 +844,7 @@ bitor_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 BitXorAssign<Rhs = Self> {
|
||||
/// Performs the `^=` operation.
|
||||
///
|
||||
|
@ -61,7 +61,7 @@
|
||||
#[doc(alias = "&*")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_diagnostic_item = "Deref"]
|
||||
#[const_trait]
|
||||
#[cfg_attr(not(bootstrap), const_trait)]
|
||||
pub trait Deref {
|
||||
/// The resulting type after dereferencing.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -170,6 +170,7 @@ impl<T: ?Sized> const Deref for &mut T {
|
||||
#[lang = "deref_mut"]
|
||||
#[doc(alias = "*")]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[const_trait]
|
||||
pub trait DerefMut: Deref {
|
||||
/// Mutably dereferences the value.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
|
@ -55,7 +55,7 @@
|
||||
#[doc(alias = "]")]
|
||||
#[doc(alias = "[")]
|
||||
#[doc(alias = "[]")]
|
||||
#[const_trait]
|
||||
#[cfg_attr(not(bootstrap), const_trait)]
|
||||
pub trait Index<Idx: ?Sized> {
|
||||
/// The returned type after indexing.
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
@ -164,7 +164,7 @@ see chapter in The Book <https://doc.rust-lang.org/book/ch08-02-strings.html#ind
|
||||
#[doc(alias = "[")]
|
||||
#[doc(alias = "]")]
|
||||
#[doc(alias = "[]")]
|
||||
#[const_trait]
|
||||
#[cfg_attr(not(bootstrap), const_trait)]
|
||||
pub trait IndexMut<Idx: ?Sized>: Index<Idx> {
|
||||
/// Performs the mutable indexing (`container[index]`) operation.
|
||||
///
|
||||
|
Loading…
Reference in New Issue
Block a user