Replace #[const_trait] with const in libcore

This commit is contained in:
León Orell Valerian Liehr 2025-11-08 06:40:27 +01:00
parent 843f8ce2eb
commit 8aedbf12f6
No known key found for this signature in database
GPG key ID: D17A07215F68E713
5 changed files with 11 additions and 22 deletions

View file

@ -132,9 +132,8 @@ where
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<T: [const] Eq, const N: usize> const Eq for [T; N] {}
#[const_trait]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
trait SpecArrayEq<Other, const N: usize>: Sized {
const trait SpecArrayEq<Other, const N: usize>: Sized {
fn spec_eq(a: &[Self; N], b: &[Other; N]) -> bool;
fn spec_ne(a: &[Self; N], b: &[Other; N]) -> bool;
}

View file

@ -17,8 +17,7 @@ use crate::num::NonZero;
/// - Neither `Self` nor `Rhs` have provenance, so integer comparisons are correct.
/// - `<Self as PartialEq<Rhs>>::{eq,ne}` are equivalent to comparing the bytes.
#[rustc_specialization_trait]
#[const_trait] // FIXME(const_trait_impl): Migrate to `const unsafe trait` once #146122 is fixed.
pub(crate) unsafe trait BytewiseEq<Rhs = Self>:
pub(crate) const unsafe trait BytewiseEq<Rhs = Self>:
[const] PartialEq<Rhs> + Sized
{
}

View file

@ -816,9 +816,8 @@ impl<T: Clone> Bound<&T> {
/// by range syntax like `..`, `a..`, `..b`, `..=c`, `d..e`, or `f..=g`.
#[stable(feature = "collections_range", since = "1.28.0")]
#[rustc_diagnostic_item = "RangeBounds"]
#[const_trait]
#[rustc_const_unstable(feature = "const_range", issue = "none")]
pub trait RangeBounds<T: ?Sized> {
pub const trait RangeBounds<T: ?Sized> {
/// Start index bound.
///
/// Returns the start value as a `Bound`.
@ -954,9 +953,8 @@ pub trait RangeBounds<T: ?Sized> {
/// `IntoBounds` is implemented by Rusts built-in range types, produced
/// by range syntax like `..`, `a..`, `..b`, `..=c`, `d..e`, or `f..=g`.
#[unstable(feature = "range_into_bounds", issue = "136903")]
#[const_trait]
#[rustc_const_unstable(feature = "const_range", issue = "none")]
pub trait IntoBounds<T>: [const] RangeBounds<T> {
pub const trait IntoBounds<T>: [const] RangeBounds<T> {
/// Convert this range into the start and end bounds.
/// Returns `(start_bound, end_bound)`.
///
@ -1319,9 +1317,8 @@ pub enum OneSidedRangeBound {
/// Types that implement `OneSidedRange<T>` must return `Bound::Unbounded`
/// from one of `RangeBounds::start_bound` or `RangeBounds::end_bound`.
#[unstable(feature = "one_sided_range", issue = "69780")]
#[const_trait]
#[rustc_const_unstable(feature = "const_range", issue = "none")]
pub trait OneSidedRange<T>: RangeBounds<T> {
pub const trait OneSidedRange<T>: RangeBounds<T> {
/// An internal-only helper function for `split_off` and
/// `split_off_mut` that returns the bound of the one-sided range.
fn bound(self) -> (OneSidedRangeBound, T);

View file

@ -155,18 +155,16 @@ where
}
#[doc(hidden)]
#[const_trait]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
// intermediate trait for specialization of slice's PartialOrd
trait SlicePartialOrd: Sized {
const trait SlicePartialOrd: Sized {
fn partial_compare(left: &[Self], right: &[Self]) -> Option<Ordering>;
}
#[doc(hidden)]
#[const_trait]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
// intermediate trait for specialization of slice's PartialOrd chaining methods
trait SliceChain: Sized {
const trait SliceChain: Sized {
fn chaining_lt(left: &[Self], right: &[Self]) -> ControlFlow<bool>;
fn chaining_le(left: &[Self], right: &[Self]) -> ControlFlow<bool>;
fn chaining_gt(left: &[Self], right: &[Self]) -> ControlFlow<bool>;
@ -244,9 +242,8 @@ impl<A: [const] AlwaysApplicableOrd> const SlicePartialOrd for A {
}
#[rustc_specialization_trait]
#[const_trait]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
trait AlwaysApplicableOrd: [const] SliceOrd + [const] Ord {}
const trait AlwaysApplicableOrd: [const] SliceOrd + [const] Ord {}
macro_rules! always_applicable_ord {
($([$($p:tt)*] $t:ty,)*) => {
@ -265,10 +262,9 @@ always_applicable_ord! {
}
#[doc(hidden)]
#[const_trait]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
// intermediate trait for specialization of slice's Ord
trait SliceOrd: Sized {
const trait SliceOrd: Sized {
fn compare(left: &[Self], right: &[Self]) -> Ordering;
}
@ -292,8 +288,7 @@ impl<A: Ord> SliceOrd for A {
/// * For every `x` and `y` of this type, `Ord(x, y)` must return the same
/// value as `Ord::cmp(transmute::<_, u8>(x), transmute::<_, u8>(y))`.
#[rustc_specialization_trait]
#[const_trait]
unsafe trait UnsignedBytewiseOrd: [const] Ord {}
const unsafe trait UnsignedBytewiseOrd: [const] Ord {}
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
unsafe impl const UnsignedBytewiseOrd for bool {}

View file

@ -159,9 +159,8 @@ mod private_slice_index {
message = "the type `{T}` cannot be indexed by `{Self}`",
label = "slice indices are of type `usize` or ranges of `usize`"
)]
#[const_trait] // FIXME(const_trait_impl): Migrate to `const unsafe trait` once #146122 is fixed.
#[rustc_const_unstable(feature = "const_index", issue = "143775")]
pub unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
pub const unsafe trait SliceIndex<T: ?Sized>: private_slice_index::Sealed {
/// The output type returned by methods.
#[stable(feature = "slice_get_slice", since = "1.28.0")]
type Output: ?Sized;