Skip to content

Commit fe87efe

Browse files
committed
Suggest deriving traits if possible
This only applies to builtin derives as I don't think there is a clean way to get the available derives in typeck. Closes rust-lang#85851
1 parent 02a230e commit fe87efe

File tree

3 files changed

+6
-0
lines changed

3 files changed

+6
-0
lines changed

core/src/cmp.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,7 @@ use self::Ordering::*;
203203
message = "can't compare `{Self}` with `{Rhs}`",
204204
label = "no implementation for `{Self} == {Rhs}`"
205205
)]
206+
#[rustc_diagnostic_item = "PartialEq"]
206207
pub trait PartialEq<Rhs: ?Sized = Self> {
207208
/// This method tests for `self` and `other` values to be equal, and is used
208209
/// by `==`.
@@ -269,6 +270,7 @@ pub macro PartialEq($item:item) {
269270
#[doc(alias = "==")]
270271
#[doc(alias = "!=")]
271272
#[stable(feature = "rust1", since = "1.0.0")]
273+
#[rustc_diagnostic_item = "Eq"]
272274
pub trait Eq: PartialEq<Self> {
273275
// this method is used solely by #[deriving] to assert
274276
// that every component of a type implements #[deriving]
@@ -728,6 +730,7 @@ impl<T: Clone> Clone for Reverse<T> {
728730
#[doc(alias = "<=")]
729731
#[doc(alias = ">=")]
730732
#[stable(feature = "rust1", since = "1.0.0")]
733+
#[rustc_diagnostic_item = "Ord"]
731734
pub trait Ord: Eq + PartialOrd<Self> {
732735
/// This method returns an [`Ordering`] between `self` and `other`.
733736
///
@@ -984,6 +987,7 @@ impl PartialOrd for Ordering {
984987
message = "can't compare `{Self}` with `{Rhs}`",
985988
label = "no implementation for `{Self} < {Rhs}` and `{Self} > {Rhs}`"
986989
)]
990+
#[rustc_diagnostic_item = "PartialOrd"]
987991
pub trait PartialOrd<Rhs: ?Sized = Self>: PartialEq<Rhs> {
988992
/// This method returns an ordering between `self` and `other` values if one exists.
989993
///

core/src/hash/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ mod sip;
157157
/// [`HashSet`]: ../../std/collections/struct.HashSet.html
158158
/// [`hash`]: Hash::hash
159159
#[stable(feature = "rust1", since = "1.0.0")]
160+
#[rustc_diagnostic_item = "Hash"]
160161
pub trait Hash {
161162
/// Feeds this value into the given [`Hasher`].
162163
///

core/src/marker.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,7 @@ pub trait StructuralEq {
382382
// existing specializations on `Copy` that already exist in the standard
383383
// library, and there's no way to safely have this behavior right now.
384384
#[rustc_unsafe_specialization_marker]
385+
#[rustc_diagnostic_item = "Copy"]
385386
pub trait Copy: Clone {
386387
// Empty.
387388
}

0 commit comments

Comments
 (0)