Convert Eq impl to check Ord::Equal

This commit is contained in:
kadmin 2020-08-09 07:50:56 +00:00
parent be0d6f1c06
commit 64f6437822
2 changed files with 8 additions and 2 deletions

View file

@ -310,7 +310,7 @@ pub type GenericBounds = Vec<GenericBound>;
/// Specifies the enforced ordering for generic parameters. In the future,
/// if we wanted to relax this order, we could override `PartialEq` and
/// `PartialOrd`, to allow the kinds to be unordered.
#[derive(PartialEq, Eq, Hash, Clone, Copy)]
#[derive(Hash, Clone, Copy)]
pub enum ParamKindOrd {
Lifetime,
Type,
@ -340,6 +340,12 @@ impl PartialOrd for ParamKindOrd {
Some(self.cmp(other))
}
}
impl PartialEq for ParamKindOrd {
fn eq(&self, other: &Self) -> bool {
self.cmp(other) == Ordering::Equal
}
}
impl Eq for ParamKindOrd {}
impl fmt::Display for ParamKindOrd {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {

View file

@ -11,7 +11,7 @@ LL | let _: AlsoBad<7, 'static, u32, 'static, 17, u16>;
| ^^^^^^^
|
= note: lifetime arguments must be provided before type arguments
= help: reorder the arguments: lifetimes, then consts, then types, then consts, then types: `<'a, 'b, N, T, M, U>`
= help: reorder the arguments: lifetimes, then consts: `<'a, 'b, N, T, M, U>`
error: aborting due to 2 previous errors