Skip to content

Commit 577a750

Browse files
committed
clean up some old const trait impl syntax
1 parent 07d246f commit 577a750

File tree

21 files changed

+54
-102
lines changed

21 files changed

+54
-102
lines changed

library/core/src/clone.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,8 +191,7 @@ mod uninit;
191191
#[rustc_diagnostic_item = "Clone"]
192192
#[rustc_trivial_field_reads]
193193
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
194-
#[const_trait]
195-
pub trait Clone: Sized {
194+
pub const trait Clone: Sized {
196195
/// Returns a duplicate of the value.
197196
///
198197
/// Note that what "duplicate" means varies by type:

library/core/src/cmp.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -247,9 +247,8 @@ use crate::ops::ControlFlow;
247247
append_const_msg
248248
)]
249249
#[rustc_diagnostic_item = "PartialEq"]
250-
#[const_trait]
251250
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
252-
pub trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
251+
pub const trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized {
253252
/// Tests for `self` and `other` values to be equal, and is used by `==`.
254253
#[must_use]
255254
#[stable(feature = "rust1", since = "1.0.0")]

library/core/src/convert/mod.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,8 @@ pub const fn identity<T>(x: T) -> T {
216216
/// ```
217217
#[stable(feature = "rust1", since = "1.0.0")]
218218
#[rustc_diagnostic_item = "AsRef"]
219-
#[const_trait]
220219
#[rustc_const_unstable(feature = "const_try", issue = "74935")]
221-
pub trait AsRef<T: PointeeSized>: PointeeSized {
220+
pub const trait AsRef<T: PointeeSized>: PointeeSized {
222221
/// Converts this type into a shared reference of the (usually inferred) input type.
223222
#[stable(feature = "rust1", since = "1.0.0")]
224223
fn as_ref(&self) -> &T;
@@ -369,9 +368,8 @@ pub trait AsRef<T: PointeeSized>: PointeeSized {
369368
/// `&mut Vec<u8>`, for example, is the better choice (callers need to pass the correct type then).
370369
#[stable(feature = "rust1", since = "1.0.0")]
371370
#[rustc_diagnostic_item = "AsMut"]
372-
#[const_trait]
373371
#[rustc_const_unstable(feature = "const_try", issue = "74935")]
374-
pub trait AsMut<T: PointeeSized>: PointeeSized {
372+
pub const trait AsMut<T: PointeeSized>: PointeeSized {
375373
/// Converts this type into a mutable reference of the (usually inferred) input type.
376374
#[stable(feature = "rust1", since = "1.0.0")]
377375
fn as_mut(&mut self) -> &mut T;
@@ -450,8 +448,7 @@ pub trait AsMut<T: PointeeSized>: PointeeSized {
450448
#[stable(feature = "rust1", since = "1.0.0")]
451449
#[doc(search_unbox)]
452450
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
453-
#[const_trait]
454-
pub trait Into<T>: Sized {
451+
pub const trait Into<T>: Sized {
455452
/// Converts this type into the (usually inferred) input type.
456453
#[must_use]
457454
#[stable(feature = "rust1", since = "1.0.0")]
@@ -587,8 +584,7 @@ pub trait Into<T>: Sized {
587584
))]
588585
#[doc(search_unbox)]
589586
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
590-
#[const_trait]
591-
pub trait From<T>: Sized {
587+
pub const trait From<T>: Sized {
592588
/// Converts to this type from the input type.
593589
#[rustc_diagnostic_item = "from_fn"]
594590
#[must_use]
@@ -616,8 +612,7 @@ pub trait From<T>: Sized {
616612
#[rustc_diagnostic_item = "TryInto"]
617613
#[stable(feature = "try_from", since = "1.34.0")]
618614
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
619-
#[const_trait]
620-
pub trait TryInto<T>: Sized {
615+
pub const trait TryInto<T>: Sized {
621616
/// The type returned in the event of a conversion error.
622617
#[stable(feature = "try_from", since = "1.34.0")]
623618
type Error;
@@ -696,8 +691,7 @@ pub trait TryInto<T>: Sized {
696691
#[rustc_diagnostic_item = "TryFrom"]
697692
#[stable(feature = "try_from", since = "1.34.0")]
698693
#[rustc_const_unstable(feature = "const_from", issue = "143773")]
699-
#[const_trait]
700-
pub trait TryFrom<T>: Sized {
694+
pub const trait TryFrom<T>: Sized {
701695
/// The type returned in the event of a conversion error.
702696
#[stable(feature = "try_from", since = "1.34.0")]
703697
type Error;

library/core/src/default.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,8 @@ use crate::ascii::Char as AsciiChar;
103103
/// ```
104104
#[rustc_diagnostic_item = "Default"]
105105
#[stable(feature = "rust1", since = "1.0.0")]
106-
#[const_trait]
107106
#[rustc_const_unstable(feature = "const_default", issue = "143894")]
108-
pub trait Default: Sized {
107+
pub const trait Default: Sized {
109108
/// Returns the "default value" for a type.
110109
///
111110
/// Default values are often some kind of initial value, identity value, or anything else that

library/core/src/intrinsics/fallback.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,8 @@
77
)]
88
#![allow(missing_docs)]
99

10-
#[const_trait]
1110
#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
12-
pub trait CarryingMulAdd: Copy + 'static {
11+
pub const trait CarryingMulAdd: Copy + 'static {
1312
type Unsigned: Copy + 'static;
1413
fn carrying_mul_add(
1514
self,
@@ -111,9 +110,8 @@ impl const CarryingMulAdd for i128 {
111110
}
112111
}
113112

114-
#[const_trait]
115113
#[rustc_const_unstable(feature = "core_intrinsics_fallbacks", issue = "none")]
116-
pub trait DisjointBitOr: Copy + 'static {
114+
pub const trait DisjointBitOr: Copy + 'static {
117115
/// See [`super::disjoint_bitor`]; we just need the trait indirection to handle
118116
/// different types since calling intrinsics with generics doesn't work.
119117
unsafe fn disjoint_bitor(self, other: Self) -> Self;

library/core/src/marker.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1057,8 +1057,7 @@ marker_impls! {
10571057
#[rustc_on_unimplemented(message = "can't drop `{Self}`", append_const_msg)]
10581058
#[rustc_deny_explicit_impl]
10591059
#[rustc_do_not_implement_via_object]
1060-
#[const_trait]
1061-
pub trait Destruct {}
1060+
pub const trait Destruct {}
10621061

10631062
/// A marker for tuple types.
10641063
///

library/core/src/ops/arith.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,7 @@
7474
append_const_msg
7575
)]
7676
#[doc(alias = "+")]
77-
#[const_trait]
78-
pub trait Add<Rhs = Self> {
77+
pub const trait Add<Rhs = Self> {
7978
/// The resulting type after applying the `+` operator.
8079
#[stable(feature = "rust1", since = "1.0.0")]
8180
type Output;
@@ -188,8 +187,7 @@ add_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128
188187
append_const_msg
189188
)]
190189
#[doc(alias = "-")]
191-
#[const_trait]
192-
pub trait Sub<Rhs = Self> {
190+
pub const trait Sub<Rhs = Self> {
193191
/// The resulting type after applying the `-` operator.
194192
#[stable(feature = "rust1", since = "1.0.0")]
195193
type Output;
@@ -323,8 +321,7 @@ sub_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128
323321
label = "no implementation for `{Self} * {Rhs}`"
324322
)]
325323
#[doc(alias = "*")]
326-
#[const_trait]
327-
pub trait Mul<Rhs = Self> {
324+
pub const trait Mul<Rhs = Self> {
328325
/// The resulting type after applying the `*` operator.
329326
#[stable(feature = "rust1", since = "1.0.0")]
330327
type Output;
@@ -462,8 +459,7 @@ mul_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f64 f128
462459
label = "no implementation for `{Self} / {Rhs}`"
463460
)]
464461
#[doc(alias = "/")]
465-
#[const_trait]
466-
pub trait Div<Rhs = Self> {
462+
pub const trait Div<Rhs = Self> {
467463
/// The resulting type after applying the `/` operator.
468464
#[stable(feature = "rust1", since = "1.0.0")]
469465
type Output;
@@ -572,8 +568,7 @@ div_impl_float! { f16 f32 f64 f128 }
572568
label = "no implementation for `{Self} % {Rhs}`"
573569
)]
574570
#[doc(alias = "%")]
575-
#[const_trait]
576-
pub trait Rem<Rhs = Self> {
571+
pub const trait Rem<Rhs = Self> {
577572
/// The resulting type after applying the `%` operator.
578573
#[stable(feature = "rust1", since = "1.0.0")]
579574
type Output;
@@ -694,8 +689,7 @@ rem_impl_float! { f16 f32 f64 f128 }
694689
#[stable(feature = "rust1", since = "1.0.0")]
695690
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
696691
#[doc(alias = "-")]
697-
#[const_trait]
698-
pub trait Neg {
692+
pub const trait Neg {
699693
/// The resulting type after applying the `-` operator.
700694
#[stable(feature = "rust1", since = "1.0.0")]
701695
type Output;
@@ -772,8 +766,7 @@ neg_impl! { isize i8 i16 i32 i64 i128 f16 f32 f64 f128 }
772766
)]
773767
#[doc(alias = "+")]
774768
#[doc(alias = "+=")]
775-
#[const_trait]
776-
pub trait AddAssign<Rhs = Self> {
769+
pub const trait AddAssign<Rhs = Self> {
777770
/// Performs the `+=` operation.
778771
///
779772
/// # Example
@@ -844,8 +837,7 @@ add_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f
844837
)]
845838
#[doc(alias = "-")]
846839
#[doc(alias = "-=")]
847-
#[const_trait]
848-
pub trait SubAssign<Rhs = Self> {
840+
pub const trait SubAssign<Rhs = Self> {
849841
/// Performs the `-=` operation.
850842
///
851843
/// # Example
@@ -907,8 +899,7 @@ sub_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f
907899
)]
908900
#[doc(alias = "*")]
909901
#[doc(alias = "*=")]
910-
#[const_trait]
911-
pub trait MulAssign<Rhs = Self> {
902+
pub const trait MulAssign<Rhs = Self> {
912903
/// Performs the `*=` operation.
913904
///
914905
/// # Example
@@ -970,8 +961,7 @@ mul_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f
970961
)]
971962
#[doc(alias = "/")]
972963
#[doc(alias = "/=")]
973-
#[const_trait]
974-
pub trait DivAssign<Rhs = Self> {
964+
pub const trait DivAssign<Rhs = Self> {
975965
/// Performs the `/=` operation.
976966
///
977967
/// # Example
@@ -1036,8 +1026,7 @@ div_assign_impl! { usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 f16 f32 f
10361026
)]
10371027
#[doc(alias = "%")]
10381028
#[doc(alias = "%=")]
1039-
#[const_trait]
1040-
pub trait RemAssign<Rhs = Self> {
1029+
pub const trait RemAssign<Rhs = Self> {
10411030
/// Performs the `%=` operation.
10421031
///
10431032
/// # Example

library/core/src/ops/bit.rs

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@
3232
#[stable(feature = "rust1", since = "1.0.0")]
3333
#[rustc_const_unstable(feature = "const_ops", issue = "143802")]
3434
#[doc(alias = "!")]
35-
#[const_trait]
36-
pub trait Not {
35+
pub const trait Not {
3736
/// The resulting type after applying the `!` operator.
3837
#[stable(feature = "rust1", since = "1.0.0")]
3938
type Output;
@@ -148,8 +147,7 @@ impl const Not for ! {
148147
message = "no implementation for `{Self} & {Rhs}`",
149148
label = "no implementation for `{Self} & {Rhs}`"
150149
)]
151-
#[const_trait]
152-
pub trait BitAnd<Rhs = Self> {
150+
pub const trait BitAnd<Rhs = Self> {
153151
/// The resulting type after applying the `&` operator.
154152
#[stable(feature = "rust1", since = "1.0.0")]
155153
type Output;
@@ -253,8 +251,7 @@ bitand_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
253251
message = "no implementation for `{Self} | {Rhs}`",
254252
label = "no implementation for `{Self} | {Rhs}`"
255253
)]
256-
#[const_trait]
257-
pub trait BitOr<Rhs = Self> {
254+
pub const trait BitOr<Rhs = Self> {
258255
/// The resulting type after applying the `|` operator.
259256
#[stable(feature = "rust1", since = "1.0.0")]
260257
type Output;
@@ -358,8 +355,7 @@ bitor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
358355
message = "no implementation for `{Self} ^ {Rhs}`",
359356
label = "no implementation for `{Self} ^ {Rhs}`"
360357
)]
361-
#[const_trait]
362-
pub trait BitXor<Rhs = Self> {
358+
pub const trait BitXor<Rhs = Self> {
363359
/// The resulting type after applying the `^` operator.
364360
#[stable(feature = "rust1", since = "1.0.0")]
365361
type Output;
@@ -462,8 +458,7 @@ bitxor_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
462458
message = "no implementation for `{Self} << {Rhs}`",
463459
label = "no implementation for `{Self} << {Rhs}`"
464460
)]
465-
#[const_trait]
466-
pub trait Shl<Rhs = Self> {
461+
pub const trait Shl<Rhs = Self> {
467462
/// The resulting type after applying the `<<` operator.
468463
#[stable(feature = "rust1", since = "1.0.0")]
469464
type Output;
@@ -585,8 +580,7 @@ shl_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
585580
message = "no implementation for `{Self} >> {Rhs}`",
586581
label = "no implementation for `{Self} >> {Rhs}`"
587582
)]
588-
#[const_trait]
589-
pub trait Shr<Rhs = Self> {
583+
pub const trait Shr<Rhs = Self> {
590584
/// The resulting type after applying the `>>` operator.
591585
#[stable(feature = "rust1", since = "1.0.0")]
592586
type Output;
@@ -717,8 +711,7 @@ shr_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
717711
message = "no implementation for `{Self} &= {Rhs}`",
718712
label = "no implementation for `{Self} &= {Rhs}`"
719713
)]
720-
#[const_trait]
721-
pub trait BitAndAssign<Rhs = Self> {
714+
pub const trait BitAndAssign<Rhs = Self> {
722715
/// Performs the `&=` operation.
723716
///
724717
/// # Examples
@@ -793,8 +786,7 @@ bitand_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
793786
message = "no implementation for `{Self} |= {Rhs}`",
794787
label = "no implementation for `{Self} |= {Rhs}`"
795788
)]
796-
#[const_trait]
797-
pub trait BitOrAssign<Rhs = Self> {
789+
pub const trait BitOrAssign<Rhs = Self> {
798790
/// Performs the `|=` operation.
799791
///
800792
/// # Examples
@@ -869,8 +861,7 @@ bitor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
869861
message = "no implementation for `{Self} ^= {Rhs}`",
870862
label = "no implementation for `{Self} ^= {Rhs}`"
871863
)]
872-
#[const_trait]
873-
pub trait BitXorAssign<Rhs = Self> {
864+
pub const trait BitXorAssign<Rhs = Self> {
874865
/// Performs the `^=` operation.
875866
///
876867
/// # Examples
@@ -943,8 +934,7 @@ bitxor_assign_impl! { bool usize u8 u16 u32 u64 u128 isize i8 i16 i32 i64 i128 }
943934
message = "no implementation for `{Self} <<= {Rhs}`",
944935
label = "no implementation for `{Self} <<= {Rhs}`"
945936
)]
946-
#[const_trait]
947-
pub trait ShlAssign<Rhs = Self> {
937+
pub const trait ShlAssign<Rhs = Self> {
948938
/// Performs the `<<=` operation.
949939
///
950940
/// # Examples
@@ -1030,8 +1020,7 @@ shl_assign_impl_all! { u8 u16 u32 u64 u128 usize i8 i16 i32 i64 i128 isize }
10301020
message = "no implementation for `{Self} >>= {Rhs}`",
10311021
label = "no implementation for `{Self} >>= {Rhs}`"
10321022
)]
1033-
#[const_trait]
1034-
pub trait ShrAssign<Rhs = Self> {
1023+
pub const trait ShrAssign<Rhs = Self> {
10351024
/// Performs the `>>=` operation.
10361025
///
10371026
/// # Examples

library/core/src/ops/deref.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,8 @@ use crate::marker::PointeeSized;
135135
#[doc(alias = "&*")]
136136
#[stable(feature = "rust1", since = "1.0.0")]
137137
#[rustc_diagnostic_item = "Deref"]
138-
#[const_trait]
139138
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
140-
pub trait Deref: PointeeSized {
139+
pub const trait Deref: PointeeSized {
141140
/// The resulting type after dereferencing.
142141
#[stable(feature = "rust1", since = "1.0.0")]
143142
#[rustc_diagnostic_item = "deref_target"]
@@ -267,9 +266,8 @@ impl<T: ?Sized> const Deref for &mut T {
267266
#[lang = "deref_mut"]
268267
#[doc(alias = "*")]
269268
#[stable(feature = "rust1", since = "1.0.0")]
270-
#[const_trait]
271269
#[rustc_const_unstable(feature = "const_deref", issue = "88955")]
272-
pub trait DerefMut: [const] Deref + PointeeSized {
270+
pub const trait DerefMut: [const] Deref + PointeeSized {
273271
/// Mutably dereferences the value.
274272
#[stable(feature = "rust1", since = "1.0.0")]
275273
#[rustc_diagnostic_item = "deref_mut_method"]

library/core/src/ops/drop.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,9 +203,8 @@
203203
/// [nomicon]: ../../nomicon/phantom-data.html#an-exception-the-special-case-of-the-standard-library-and-its-unstable-may_dangle
204204
#[lang = "drop"]
205205
#[stable(feature = "rust1", since = "1.0.0")]
206-
#[const_trait]
207206
#[rustc_const_unstable(feature = "const_destruct", issue = "133214")]
208-
pub trait Drop {
207+
pub const trait Drop {
209208
/// Executes the destructor for this type.
210209
///
211210
/// This method is called implicitly when the value goes out of scope,

0 commit comments

Comments
 (0)