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
6 changes: 4 additions & 2 deletions library/core/src/alloc/layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ const fn size_align<T>() -> (usize, usize) {
/// like this are met, use specific allocators with looser
/// requirements, or use the more lenient `Allocator` interface.)
#[stable(feature = "alloc_layout", since = "1.28.0")]
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, Debug, Hash)]
#[derive_const(PartialEq, Eq)]
#[lang = "alloc_layout"]
pub struct Layout {
// size of the requested block of memory, measured in bytes.
Expand Down Expand Up @@ -545,7 +546,8 @@ pub type LayoutErr = LayoutError;
/// do not satisfy its documented constraints.
#[stable(feature = "alloc_layout_error", since = "1.50.0")]
#[non_exhaustive]
#[derive(Clone, PartialEq, Eq, Debug)]
#[derive(Clone, Debug)]
#[derive_const(PartialEq, Eq)]
pub struct LayoutError;

#[stable(feature = "alloc_layout", since = "1.28.0")]
Expand Down
17 changes: 11 additions & 6 deletions library/core/src/array/equality.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
use crate::cmp::BytewiseEq;

#[stable(feature = "rust1", since = "1.0.0")]
impl<T, U, const N: usize> PartialEq<[U; N]> for [T; N]
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<T, U, const N: usize> const PartialEq<[U; N]> for [T; N]
where
T: PartialEq<U>,
T: [const] PartialEq<U>,
{
#[inline]
fn eq(&self, other: &[U; N]) -> bool {
Expand Down Expand Up @@ -122,14 +123,17 @@ where
// __impl_slice_eq2! { [A; $N], &'b mut [B; $N] }

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Eq, const N: usize> Eq for [T; N] {}
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<T: [const] Eq, const N: usize> const Eq for [T; N] {}

trait SpecArrayEq<Other, const N: usize>: Sized {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
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;
}

impl<T: PartialEq<Other>, Other, const N: usize> SpecArrayEq<Other, N> for T {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<T: [const] PartialEq<Other>, Other, const N: usize> const SpecArrayEq<Other, N> for T {
default fn spec_eq(a: &[Self; N], b: &[Other; N]) -> bool {
a[..] == b[..]
}
Expand All @@ -138,7 +142,8 @@ impl<T: PartialEq<Other>, Other, const N: usize> SpecArrayEq<Other, N> for T {
}
}

impl<T: BytewiseEq<U>, U, const N: usize> SpecArrayEq<U, N> for T {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<T: [const] BytewiseEq<U>, U, const N: usize> const SpecArrayEq<U, N> for T {
fn spec_eq(a: &[T; N], b: &[U; N]) -> bool {
// SAFETY: Arrays are compared element-wise, and don't add any padding
// between elements, so when the elements are `BytewiseEq`, we can
Expand Down
6 changes: 4 additions & 2 deletions library/core/src/array/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,8 @@ where

/// Implements comparison of arrays [lexicographically](Ord#lexicographical-comparison).
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PartialOrd, const N: usize> PartialOrd for [T; N] {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<T: [const] PartialOrd, const N: usize> const PartialOrd for [T; N] {
#[inline]
fn partial_cmp(&self, other: &[T; N]) -> Option<Ordering> {
PartialOrd::partial_cmp(&&self[..], &&other[..])
Expand All @@ -428,7 +429,8 @@ impl<T: PartialOrd, const N: usize> PartialOrd for [T; N] {

/// Implements comparison of arrays [lexicographically](Ord#lexicographical-comparison).
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: Ord, const N: usize> Ord for [T; N] {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<T: [const] Ord, const N: usize> const Ord for [T; N] {
#[inline]
fn cmp(&self, other: &[T; N]) -> Ordering {
Ord::cmp(&&self[..], &&other[..])
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/ascii/ascii_char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ use crate::{assert_unsafe_precondition, fmt};
/// [chart]: https://www.unicode.org/charts/PDF/U0000.pdf
/// [NIST FIPS 1-2]: https://nvlpubs.nist.gov/nistpubs/Legacy/FIPS/fipspub1-2-1977.pdf
/// [NamesList]: https://www.unicode.org/Public/15.0.0/ucd/NamesList.txt
#[derive(Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Copy, Clone, Hash)]
#[derive_const(Eq, PartialEq, Ord, PartialOrd)]
#[unstable(feature = "ascii_char", issue = "110998")]
#[repr(u8)]
pub enum AsciiChar {
Expand Down
12 changes: 8 additions & 4 deletions library/core/src/bstr/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,35 @@ use crate::slice::SliceIndex;
use crate::{hash, ops, range};

#[unstable(feature = "bstr", issue = "134915")]
impl Ord for ByteStr {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const Ord for ByteStr {
#[inline]
fn cmp(&self, other: &ByteStr) -> Ordering {
Ord::cmp(&self.0, &other.0)
}
}

#[unstable(feature = "bstr", issue = "134915")]
impl PartialOrd for ByteStr {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const PartialOrd for ByteStr {
#[inline]
fn partial_cmp(&self, other: &ByteStr) -> Option<Ordering> {
PartialOrd::partial_cmp(&self.0, &other.0)
}
}

#[unstable(feature = "bstr", issue = "134915")]
impl PartialEq<ByteStr> for ByteStr {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const PartialEq<ByteStr> for ByteStr {
#[inline]
fn eq(&self, other: &ByteStr) -> bool {
&self.0 == &other.0
}
}

#[unstable(feature = "bstr", issue = "134915")]
impl Eq for ByteStr {}
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const Eq for ByteStr {}

#[unstable(feature = "bstr", issue = "134915")]
impl hash::Hash for ByteStr {
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/char/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,8 @@ impl fmt::Display for CaseMappingIter {

/// The error type returned when a checked char conversion fails.
#[stable(feature = "u8_from_char", since = "1.59.0")]
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(Debug, Copy, Clone)]
#[derive_const(PartialEq, Eq)]
pub struct TryFromCharError(pub(crate) ());

#[stable(feature = "u8_from_char", since = "1.59.0")]
Expand Down
Loading
Loading