Skip to content

Commit 8aedbf1

Browse files
committed
Replace #[const_trait] with const in libcore
1 parent 843f8ce commit 8aedbf1

File tree

5 files changed

+11
-22
lines changed

5 files changed

+11
-22
lines changed

library/core/src/array/equality.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,9 +132,8 @@ where
132132
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
133133
impl<T: [const] Eq, const N: usize> const Eq for [T; N] {}
134134

135-
#[const_trait]
136135
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
137-
trait SpecArrayEq<Other, const N: usize>: Sized {
136+
const trait SpecArrayEq<Other, const N: usize>: Sized {
138137
fn spec_eq(a: &[Self; N], b: &[Other; N]) -> bool;
139138
fn spec_ne(a: &[Self; N], b: &[Other; N]) -> bool;
140139
}

library/core/src/cmp/bytewise.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,7 @@ use crate::num::NonZero;
1717
/// - Neither `Self` nor `Rhs` have provenance, so integer comparisons are correct.
1818
/// - `<Self as PartialEq<Rhs>>::{eq,ne}` are equivalent to comparing the bytes.
1919
#[rustc_specialization_trait]
20-
#[const_trait] // FIXME(const_trait_impl): Migrate to `const unsafe trait` once #146122 is fixed.
21-
pub(crate) unsafe trait BytewiseEq<Rhs = Self>:
20+
pub(crate) const unsafe trait BytewiseEq<Rhs = Self>:
2221
[const] PartialEq<Rhs> + Sized
2322
{
2423
}

library/core/src/ops/range.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -816,9 +816,8 @@ impl<T: Clone> Bound<&T> {
816816
/// by range syntax like `..`, `a..`, `..b`, `..=c`, `d..e`, or `f..=g`.
817817
#[stable(feature = "collections_range", since = "1.28.0")]
818818
#[rustc_diagnostic_item = "RangeBounds"]
819-
#[const_trait]
820819
#[rustc_const_unstable(feature = "const_range", issue = "none")]
821-
pub trait RangeBounds<T: ?Sized> {
820+
pub const trait RangeBounds<T: ?Sized> {
822821
/// Start index bound.
823822
///
824823
/// Returns the start value as a `Bound`.
@@ -954,9 +953,8 @@ pub trait RangeBounds<T: ?Sized> {
954953
/// `IntoBounds` is implemented by Rust’s built-in range types, produced
955954
/// by range syntax like `..`, `a..`, `..b`, `..=c`, `d..e`, or `f..=g`.
956955
#[unstable(feature = "range_into_bounds", issue = "136903")]
957-
#[const_trait]
958956
#[rustc_const_unstable(feature = "const_range", issue = "none")]
959-
pub trait IntoBounds<T>: [const] RangeBounds<T> {
957+
pub const trait IntoBounds<T>: [const] RangeBounds<T> {
960958
/// Convert this range into the start and end bounds.
961959
/// Returns `(start_bound, end_bound)`.
962960
///
@@ -1319,9 +1317,8 @@ pub enum OneSidedRangeBound {
13191317
/// Types that implement `OneSidedRange<T>` must return `Bound::Unbounded`
13201318
/// from one of `RangeBounds::start_bound` or `RangeBounds::end_bound`.
13211319
#[unstable(feature = "one_sided_range", issue = "69780")]
1322-
#[const_trait]
13231320
#[rustc_const_unstable(feature = "const_range", issue = "none")]
1324-
pub trait OneSidedRange<T>: RangeBounds<T> {
1321+
pub const trait OneSidedRange<T>: RangeBounds<T> {
13251322
/// An internal-only helper function for `split_off` and
13261323
/// `split_off_mut` that returns the bound of the one-sided range.
13271324
fn bound(self) -> (OneSidedRangeBound, T);

library/core/src/slice/cmp.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -155,18 +155,16 @@ where
155155
}
156156

157157
#[doc(hidden)]
158-
#[const_trait]
159158
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
160159
// intermediate trait for specialization of slice's PartialOrd
161-
trait SlicePartialOrd: Sized {
160+
const trait SlicePartialOrd: Sized {
162161
fn partial_compare(left: &[Self], right: &[Self]) -> Option<Ordering>;
163162
}
164163

165164
#[doc(hidden)]
166-
#[const_trait]
167165
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
168166
// intermediate trait for specialization of slice's PartialOrd chaining methods
169-
trait SliceChain: Sized {
167+
const trait SliceChain: Sized {
170168
fn chaining_lt(left: &[Self], right: &[Self]) -> ControlFlow<bool>;
171169
fn chaining_le(left: &[Self], right: &[Self]) -> ControlFlow<bool>;
172170
fn chaining_gt(left: &[Self], right: &[Self]) -> ControlFlow<bool>;
@@ -244,9 +242,8 @@ impl<A: [const] AlwaysApplicableOrd> const SlicePartialOrd for A {
244242
}
245243

246244
#[rustc_specialization_trait]
247-
#[const_trait]
248245
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
249-
trait AlwaysApplicableOrd: [const] SliceOrd + [const] Ord {}
246+
const trait AlwaysApplicableOrd: [const] SliceOrd + [const] Ord {}
250247

251248
macro_rules! always_applicable_ord {
252249
($([$($p:tt)*] $t:ty,)*) => {
@@ -265,10 +262,9 @@ always_applicable_ord! {
265262
}
266263

267264
#[doc(hidden)]
268-
#[const_trait]
269265
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
270266
// intermediate trait for specialization of slice's Ord
271-
trait SliceOrd: Sized {
267+
const trait SliceOrd: Sized {
272268
fn compare(left: &[Self], right: &[Self]) -> Ordering;
273269
}
274270

@@ -292,8 +288,7 @@ impl<A: Ord> SliceOrd for A {
292288
/// * For every `x` and `y` of this type, `Ord(x, y)` must return the same
293289
/// value as `Ord::cmp(transmute::<_, u8>(x), transmute::<_, u8>(y))`.
294290
#[rustc_specialization_trait]
295-
#[const_trait]
296-
unsafe trait UnsignedBytewiseOrd: [const] Ord {}
291+
const unsafe trait UnsignedBytewiseOrd: [const] Ord {}
297292

298293
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
299294
unsafe impl const UnsignedBytewiseOrd for bool {}

library/core/src/slice/index.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,8 @@ mod private_slice_index {
159159
message = "the type `{T}` cannot be indexed by `{Self}`",
160160
label = "slice indices are of type `usize` or ranges of `usize`"
161161
)]
162-
#[const_trait] // FIXME(const_trait_impl): Migrate to `const unsafe trait` once #146122 is fixed.
163162
#[rustc_const_unstable(feature = "const_index", issue = "143775")]
164-
pub unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
163+
pub const unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
165164
/// The output type returned by methods.
166165
#[stable(feature = "slice_get_slice", since = "1.28.0")]
167166
type Output: ?Sized;

0 commit comments

Comments
 (0)