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, Debug, Hash)]
#[derive_const(Clone, 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(Debug)]
#[derive_const(Clone, PartialEq, Eq)]
pub struct LayoutError;

#[stable(feature = "alloc_layout", since = "1.28.0")]
Expand Down
3 changes: 1 addition & 2 deletions library/core/src/array/equality.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
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
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)]
#[derive_const(Clone, PartialEq, Eq)]
pub struct TryFromCharError(pub(crate) ());

#[stable(feature = "u8_from_char", since = "1.59.0")]
Expand Down
15 changes: 10 additions & 5 deletions library/core/src/clone.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,8 @@ mod impls {
($($t:ty)*) => {
$(
#[stable(feature = "rust1", since = "1.0.0")]
impl Clone for $t {
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
impl const Clone for $t {
#[inline(always)]
fn clone(&self) -> Self {
*self
Expand All @@ -593,23 +594,26 @@ mod impls {
}

#[unstable(feature = "never_type", issue = "35121")]
impl Clone for ! {
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
impl const Clone for ! {
#[inline]
fn clone(&self) -> Self {
*self
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PointeeSized> Clone for *const T {
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
impl<T: PointeeSized> const Clone for *const T {
#[inline(always)]
fn clone(&self) -> Self {
*self
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PointeeSized> Clone for *mut T {
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
impl<T: PointeeSized> const Clone for *mut T {
#[inline(always)]
fn clone(&self) -> Self {
*self
Expand All @@ -618,7 +622,8 @@ mod impls {

/// Shared references can be cloned, but mutable references *cannot*!
#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PointeeSized> Clone for &T {
#[rustc_const_unstable(feature = "const_clone", issue = "142757")]
impl<T: PointeeSized> const Clone for &T {
#[inline(always)]
#[rustc_diagnostic_item = "noop_method_clone"]
fn clone(&self) -> Self {
Expand Down
9 changes: 6 additions & 3 deletions library/core/src/ffi/c_str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ use crate::{fmt, ops, slice, str};
/// ```
///
/// [str]: prim@str "str"
#[derive(PartialEq, Eq, Hash)]
#[derive(Hash)]
#[derive_const(PartialEq, Eq)]
#[stable(feature = "core_c_str", since = "1.64.0")]
#[rustc_diagnostic_item = "cstr_type"]
#[rustc_has_incoherent_inherent_impls]
Expand Down Expand Up @@ -669,15 +670,17 @@ impl PartialEq<&Self> for CStr {
// because `c_char` is `i8` (not `u8`) on some platforms.
// That is why this is implemented manually and not derived.
#[stable(feature = "rust1", since = "1.0.0")]
impl PartialOrd for CStr {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const PartialOrd for CStr {
#[inline]
fn partial_cmp(&self, other: &CStr) -> Option<Ordering> {
self.to_bytes().partial_cmp(&other.to_bytes())
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl Ord for CStr {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl const Ord for CStr {
#[inline]
fn cmp(&self, other: &CStr) -> Ordering {
self.to_bytes().cmp(&other.to_bytes())
Expand Down
15 changes: 10 additions & 5 deletions library/core/src/fmt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ mod rt;
#[stable(feature = "fmt_flags_align", since = "1.28.0")]
#[rustc_diagnostic_item = "Alignment"]
/// Possible alignments returned by `Formatter::align`
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Debug)]
#[derive_const(Clone, PartialEq, Eq)]
pub enum Alignment {
#[stable(feature = "fmt_flags_align", since = "1.28.0")]
/// Indication that contents should be left-aligned.
Expand Down Expand Up @@ -103,7 +104,8 @@ pub type Result = result::Result<(), Error>;
/// }
/// ```
#[stable(feature = "rust1", since = "1.0.0")]
#[derive(Copy, Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[derive(Copy, Debug, Hash)]
#[derive_const(Clone, PartialEq, Eq, PartialOrd, Ord, Default)]
pub struct Error;

/// A trait for writing or formatting into Unicode-accepting buffers or streams.
Expand Down Expand Up @@ -255,7 +257,8 @@ impl<W: Write + ?Sized> Write for &mut W {
}

/// The signedness of a [`Formatter`] (or of a [`FormattingOptions`]).
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Debug)]
#[derive_const(Clone, PartialEq, Eq)]
#[unstable(feature = "formatting_options", issue = "118117")]
pub enum Sign {
/// Represents the `+` flag.
Expand All @@ -266,7 +269,8 @@ pub enum Sign {

/// Specifies whether the [`Debug`] trait should use lower-/upper-case
/// hexadecimal or normal integers.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Debug)]
#[derive_const(Clone, PartialEq, Eq)]
#[unstable(feature = "formatting_options", issue = "118117")]
pub enum DebugAsHex {
/// Use lower-case hexadecimal integers for the `Debug` trait (like [the `x?` type](../../std/fmt/index.html#formatting-traits)).
Expand All @@ -279,7 +283,8 @@ pub enum DebugAsHex {
///
/// `FormattingOptions` is a [`Formatter`] without an attached [`Write`] trait.
/// It is mainly used to construct `Formatter` instances.
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
#[derive(Copy, Debug)]
#[derive_const(Clone, PartialEq, Eq)]
#[unstable(feature = "formatting_options", issue = "118117")]
pub struct FormattingOptions {
/// Flags, with the following bit fields:
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/intrinsics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ use crate::sync::atomic::{self, AtomicBool, AtomicI32, AtomicIsize, AtomicU32, O
/// A type for atomic ordering parameters for intrinsics. This is a separate type from
/// `atomic::Ordering` so that we can make it `ConstParamTy` and fix the values used here without a
/// risk of leaking that to stable code.
#[derive(Debug, ConstParamTy, PartialEq, Eq)]
#[derive(Debug, ConstParamTy)]
#[derive_const(PartialEq, Eq)]
pub enum AtomicOrdering {
// These values must match the compiler's `AtomicOrdering` defined in
// `rustc_middle/src/ty/consts/int.rs`!
Expand Down
15 changes: 10 additions & 5 deletions library/core/src/marker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -828,24 +828,28 @@ impl<T: PointeeSized> Hash for PhantomData<T> {
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PointeeSized> cmp::PartialEq for PhantomData<T> {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<T: PointeeSized> const cmp::PartialEq for PhantomData<T> {
fn eq(&self, _other: &PhantomData<T>) -> bool {
true
}
}

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

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PointeeSized> cmp::PartialOrd for PhantomData<T> {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<T: PointeeSized> const cmp::PartialOrd for PhantomData<T> {
fn partial_cmp(&self, _other: &PhantomData<T>) -> Option<cmp::Ordering> {
Option::Some(cmp::Ordering::Equal)
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T: PointeeSized> cmp::Ord for PhantomData<T> {
#[rustc_const_unstable(feature = "const_cmp", issue = "143800")]
impl<T: PointeeSized> const cmp::Ord for PhantomData<T> {
fn cmp(&self, _other: &PhantomData<T>) -> cmp::Ordering {
cmp::Ordering::Equal
}
Expand Down Expand Up @@ -1021,7 +1025,8 @@ pub auto trait Unpin {}
// marker in your struct acts as if you wrapped the entire struct in an `UnsafePinned`. This type
// will likely eventually be deprecated, and all new code should be using `UnsafePinned` instead.
#[stable(feature = "pin", since = "1.33.0")]
#[derive(Debug, Default, Copy, Clone, Eq, PartialEq, Ord, PartialOrd, Hash)]
#[derive(Debug, Copy, Hash)]
#[derive_const(Clone, PartialEq, Eq, PartialOrd, Ord, Default)]
pub struct PhantomPinned;

#[stable(feature = "pin", since = "1.33.0")]
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/mem/manually_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,8 @@ use crate::ptr;
/// [`MaybeUninit`]: crate::mem::MaybeUninit
#[stable(feature = "manually_drop", since = "1.20.0")]
#[lang = "manually_drop"]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[derive(Copy, Debug, Hash)]
#[derive_const(Clone, PartialEq, Eq, PartialOrd, Ord, Default)]
#[repr(transparent)]
#[rustc_pub_transparent]
pub struct ManuallyDrop<T: ?Sized> {
Expand Down
3 changes: 2 additions & 1 deletion library/core/src/mem/transmutability.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,8 @@ where
/// `true`, the onus of the safety proof belongs to the programmer.
#[unstable(feature = "transmutability", issue = "99571")]
#[lang = "transmute_opts"]
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
#[derive(Copy, Debug)]
#[derive_const(Clone, PartialEq, Eq)]
pub struct Assume {
/// When `false`, [`TransmuteFrom`] is not implemented for transmutations
/// that might violate the alignment requirements of references; e.g.:
Expand Down
Loading
Loading