Skip to content

Commit

Permalink
Add diagnostic items for Ord and PartialOrd methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Urgau committed Mar 29, 2024
1 parent c5e7f45 commit 4a9f3ca
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions compiler/rustc_span/src/symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,15 @@ symbols! {
cmp,
cmp_max,
cmp_min,
cmp_ord_max,
cmp_ord_min,
cmp_partialeq_eq,
cmp_partialeq_ne,
cmp_partialord_cmp,
cmp_partialord_ge,
cmp_partialord_gt,
cmp_partialord_le,
cmp_partialord_lt,
cmpxchg16b_target_feature,
cmse_nonsecure_entry,
coerce_unsized,
Expand Down
7 changes: 7 additions & 0 deletions library/core/src/cmp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,6 +848,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
#[stable(feature = "ord_max_min", since = "1.21.0")]
#[inline]
#[must_use]
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "cmp_ord_max")]
fn max(self, other: Self) -> Self
where
Self: Sized,
Expand All @@ -868,6 +869,7 @@ pub trait Ord: Eq + PartialOrd<Self> {
#[stable(feature = "ord_max_min", since = "1.21.0")]
#[inline]
#[must_use]
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "cmp_ord_min")]
fn min(self, other: Self) -> Self
where
Self: Sized,
Expand Down Expand Up @@ -1154,6 +1156,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
/// ```
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "cmp_partialord_cmp")]
fn partial_cmp(&self, other: &Rhs) -> Option<Ordering>;

/// This method tests less than (for `self` and `other`) and is used by the `<` operator.
Expand All @@ -1168,6 +1171,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "cmp_partialord_lt")]
fn lt(&self, other: &Rhs) -> bool {
matches!(self.partial_cmp(other), Some(Less))
}
Expand All @@ -1185,6 +1189,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "cmp_partialord_le")]
fn le(&self, other: &Rhs) -> bool {
matches!(self.partial_cmp(other), Some(Less | Equal))
}
Expand All @@ -1201,6 +1206,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "cmp_partialord_gt")]
fn gt(&self, other: &Rhs) -> bool {
matches!(self.partial_cmp(other), Some(Greater))
}
Expand All @@ -1218,6 +1224,7 @@ pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
#[inline]
#[must_use]
#[stable(feature = "rust1", since = "1.0.0")]
#[cfg_attr(not(bootstrap), rustc_diagnostic_item = "cmp_partialord_ge")]
fn ge(&self, other: &Rhs) -> bool {
matches!(self.partial_cmp(other), Some(Greater | Equal))
}
Expand Down

0 comments on commit 4a9f3ca

Please sign in to comment.