Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions library/core/src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ mod uninit;
#[rustc_diagnostic_item = "Clone"]
#[rustc_trivial_field_reads]
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
#[const_trait]
pub trait Clone: Sized {
pub const trait Clone: Sized {
/// Returns a duplicate of the value.
///
/// Note that what "duplicate" means varies by type:
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,8 @@ use crate::ops::ControlFlow;
append_const_msg
)]
#[rustc_diagnostic_item = "PartialEq"]
#[const_trait]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
pub trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
pub const trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
/// Tests for `self` and `other` values to be equal, and is used by `==`.
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down
18 changes: 6 additions & 12 deletions library/core/src/convert/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,8 @@ pub const fn identity<T>(x: T) -> T {
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "AsRef"]
#[const_trait]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
pub trait AsRef<T: PointeeSized>: PointeeSized {
pub const trait AsRef<T: PointeeSized>: PointeeSized {
/// Converts this type into a shared reference of the (usually inferred) input type.
#[stable(feature = "rust1", since = "1.0.0")]
fn as_ref(&self) -> &T;
Expand Down Expand Up @@ -369,9 +368,8 @@ pub trait AsRef<T: PointeeSized>: PointeeSized {
/// `&mut Vec<u8>`, for example, is the better choice (callers need to pass the correct type then).
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "AsMut"]
#[const_trait]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
pub trait AsMut<T: PointeeSized>: PointeeSized {
pub const trait AsMut<T: PointeeSized>: PointeeSized {
/// Converts this type into a mutable reference of the (usually inferred) input type.
#[stable(feature = "rust1", since = "1.0.0")]
fn as_mut(&mut self) -> &mut T;
Expand Down Expand Up @@ -450,8 +448,7 @@ pub trait AsMut<T: PointeeSized>: PointeeSized {
#[stable(feature = "rust1", since = "1.0.0")]
#[doc(search_unbox)]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
#[const_trait]
pub trait Into<T>: Sized {
pub const trait Into<T>: Sized {
/// Converts this type into the (usually inferred) input type.
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
Expand Down Expand Up @@ -587,8 +584,7 @@ pub trait Into<T>: Sized {
))]
#[doc(search_unbox)]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
#[const_trait]
pub trait From<T>: Sized {
pub const trait From<T>: Sized {
/// Converts to this type from the input type.
#[rustc_diagnostic_item = "from_fn"]
#[must_use]
Expand Down Expand Up @@ -616,8 +612,7 @@ pub trait From<T>: Sized {
#[rustc_diagnostic_item = "TryInto"]
#[stable(feature = "try_from", since = "1.34.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
#[const_trait]
pub trait TryInto<T>: Sized {
pub const trait TryInto<T>: Sized {
/// The type returned in the event of a conversion error.
#[stable(feature = "try_from", since = "1.34.0")]
type Error;
Expand Down Expand Up @@ -696,8 +691,7 @@ pub trait TryInto<T>: Sized {
#[rustc_diagnostic_item = "TryFrom"]
#[stable(feature = "try_from", since = "1.34.0")]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
#[const_trait]
pub trait TryFrom<T>: Sized {
pub const trait TryFrom<T>: Sized {
/// The type returned in the event of a conversion error.
#[stable(feature = "try_from", since = "1.34.0")]
type Error;
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/default.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,8 @@ use crate::ascii::Char as AsciiChar;
/// ```
#[rustc_diagnostic_item = "Default"]
#[stable(feature = "rust1", since = "1.0.0")]
#[const_trait]
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
pub trait Default: Sized {
pub const trait Default: Sized {
/// Returns the "default value" for a type.
///
/// Default values are often some kind of initial value, identity value, or anything else that
Expand Down
6 changes: 2 additions & 4 deletions library/core/src/intrinsics/fallback.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
)]
#![allow(missing_docs)]

#[const_trait]
#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
pub trait CarryingMulAdd: Copy + 'static {
pub const trait CarryingMulAdd: Copy + 'static {
type Unsigned: Copy + 'static;
fn carrying_mul_add(
self,
Expand Down Expand Up @@ -111,9 +110,8 @@ impl const CarryingMulAdd for i128 {
}
}

#[const_trait]
#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
pub trait DisjointBitOr: Copy + 'static {
pub const trait DisjointBitOr: Copy + 'static {
/// See [`super::disjoint_bitor`]; we just need the trait indirection to handle
/// different types since calling intrinsics with generics doesn't work.
unsafe fn disjoint_bitor(self, other: Self) -> Self;
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1057,8 +1057,7 @@ marker_impls! {
#[rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg)]
#[rustc_deny_explicit_impl]
#[rustc_do_not_implement_via_object]
#[const_trait]
pub trait Destruct {}
pub const trait Destruct {}

/// A marker for tuple types.
///
Expand Down
33 changes: 11 additions & 22 deletions library/core/src/ops/arith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@
append_const_msg
)]
#[doc(alias = "+")]
#[const_trait]
pub trait Add<Rhs = Self> {
pub const trait Add<Rhs = Self> {
/// The resulting type after applying the `+` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -188,8 +187,7 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128
append_const_msg
)]
#[doc(alias = "-")]
#[const_trait]
pub trait Sub<Rhs = Self> {
pub const trait Sub<Rhs = Self> {
/// The resulting type after applying the `-` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -323,8 +321,7 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128
label = "no implementation for `{Self} * {Rhs}`"
)]
#[doc(alias = "*")]
#[const_trait]
pub trait Mul<Rhs = Self> {
pub const trait Mul<Rhs = Self> {
/// The resulting type after applying the `*` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -462,8 +459,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128
label = "no implementation for `{Self} / {Rhs}`"
)]
#[doc(alias = "/")]
#[const_trait]
pub trait Div<Rhs = Self> {
pub const trait Div<Rhs = Self> {
/// The resulting type after applying the `/` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -572,8 +568,7 @@ div_impl_float! { f16 f32 f64 f128 }
label = "no implementation for `{Self} % {Rhs}`"
)]
#[doc(alias = "%")]
#[const_trait]
pub trait Rem<Rhs = Self> {
pub const trait Rem<Rhs = Self> {
/// The resulting type after applying the `%` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -694,8 +689,7 @@ rem_impl_float! { f16 f32 f64 f128 }
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
#[doc(alias = "-")]
#[const_trait]
pub trait Neg {
pub const trait Neg {
/// The resulting type after applying the `-` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -772,8 +766,7 @@ neg_impl! { isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
)]
#[doc(alias = "+")]
#[doc(alias = "+=")]
#[const_trait]
pub trait AddAssign<Rhs = Self> {
pub const trait AddAssign<Rhs = Self> {
/// Performs the `+=` operation.
///
/// # Example
Expand Down Expand Up @@ -844,8 +837,7 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f
)]
#[doc(alias = "-")]
#[doc(alias = "-=")]
#[const_trait]
pub trait SubAssign<Rhs = Self> {
pub const trait SubAssign<Rhs = Self> {
/// Performs the `-=` operation.
///
/// # Example
Expand Down Expand Up @@ -907,8 +899,7 @@ sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f
)]
#[doc(alias = "*")]
#[doc(alias = "*=")]
#[const_trait]
pub trait MulAssign<Rhs = Self> {
pub const trait MulAssign<Rhs = Self> {
/// Performs the `*=` operation.
///
/// # Example
Expand Down Expand Up @@ -970,8 +961,7 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f
)]
#[doc(alias = "/")]
#[doc(alias = "/=")]
#[const_trait]
pub trait DivAssign<Rhs = Self> {
pub const trait DivAssign<Rhs = Self> {
/// Performs the `/=` operation.
///
/// # Example
Expand Down Expand Up @@ -1036,8 +1026,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f
)]
#[doc(alias = "%")]
#[doc(alias = "%=")]
#[const_trait]
pub trait RemAssign<Rhs = Self> {
pub const trait RemAssign<Rhs = Self> {
/// Performs the `%=` operation.
///
/// # Example
Expand Down
33 changes: 11 additions & 22 deletions library/core/src/ops/bit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
#[doc(alias = "!")]
#[const_trait]
pub trait Not {
pub const trait Not {
/// The resulting type after applying the `!` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -148,8 +147,7 @@ impl const Not for ! {
message = "no implementation for `{Self} & {Rhs}`",
label = "no implementation for `{Self} & {Rhs}`"
)]
#[const_trait]
pub trait BitAnd<Rhs = Self> {
pub const trait BitAnd<Rhs = Self> {
/// The resulting type after applying the `&` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -253,8 +251,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> {
pub const trait BitOr<Rhs = Self> {
/// The resulting type after applying the `|` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -358,8 +355,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> {
pub const trait BitXor<Rhs = Self> {
/// The resulting type after applying the `^` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -462,8 +458,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> {
pub const trait Shl<Rhs = Self> {
/// The resulting type after applying the `<<` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -585,8 +580,7 @@ shl_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 Shr<Rhs = Self> {
pub const trait Shr<Rhs = Self> {
/// The resulting type after applying the `>>` operator.
#[stable(feature = "rust1", since = "1.0.0")]
type Output;
Expand Down Expand Up @@ -717,8 +711,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> {
pub const trait BitAndAssign<Rhs = Self> {
/// Performs the `&=` operation.
///
/// # Examples
Expand Down Expand Up @@ -793,8 +786,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> {
pub const trait BitOrAssign<Rhs = Self> {
/// Performs the `|=` operation.
///
/// # Examples
Expand Down Expand Up @@ -869,8 +861,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> {
pub const trait BitXorAssign<Rhs = Self> {
/// Performs the `^=` operation.
///
/// # Examples
Expand Down Expand Up @@ -943,8 +934,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> {
pub const trait ShlAssign<Rhs = Self> {
/// Performs the `<<=` operation.
///
/// # Examples
Expand Down Expand Up @@ -1030,8 +1020,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> {
pub const trait ShrAssign<Rhs = Self> {
/// Performs the `>>=` operation.
///
/// # Examples
Expand Down
6 changes: 2 additions & 4 deletions library/core/src/ops/deref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,8 @@ use crate::marker::PointeeSized;
#[doc(alias = "&*")]
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "Deref"]
#[const_trait]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
pub trait Deref: PointeeSized {
pub const trait Deref: PointeeSized {
/// The resulting type after dereferencing.
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "deref_target"]
Expand Down Expand Up @@ -267,9 +266,8 @@ impl<T: ?Sized> const Deref for &mut T {
#[lang = "deref_mut"]
#[doc(alias = "*")]
#[stable(feature = "rust1", since = "1.0.0")]
#[const_trait]
#[rustc_const_unstable(feature = "const_convert", issue = "143773")]
pub trait DerefMut: [const] Deref + PointeeSized {
pub const trait DerefMut: [const] Deref + PointeeSized {
/// Mutably dereferences the value.
#[stable(feature = "rust1", since = "1.0.0")]
#[rustc_diagnostic_item = "deref_mut_method"]
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/ops/drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,9 +203,8 @@
/// [nomicon]: ../../nomicon/phantom-data.html#an-exception-the-special-case-of-the-standard-library-and-its-unstable-may_dangle
#[lang = "drop"]
#[stable(feature = "rust1", since = "1.0.0")]
#[const_trait]
#[rustc_const_unstable(feature = "const_destruct", issue = "133214")]
pub trait Drop {
pub const trait Drop {
/// Executes the destructor for this type.
///
/// This method is called implicitly when the value goes out of scope,
Expand Down
Loading
Loading