From 7eb0ef049731ddf7d66dfa8dda13ee9a706906ad Mon Sep 17 00:00:00 2001 From: toidiu Date: Sun, 9 Sep 2018 00:16:57 -0400 Subject: [PATCH] simplify ordering for Kind --- src/librustc/ty/subst.rs | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index b6ffcd55d9150..696c4d0043c14 100644 --- a/src/librustc/ty/subst.rs +++ b/src/librustc/ty/subst.rs @@ -42,7 +42,7 @@ const TAG_MASK: usize = 0b11; const TYPE_TAG: usize = 0b00; const REGION_TAG: usize = 0b01; -#[derive(Debug, RustcEncodable, RustcDecodable)] +#[derive(Debug, RustcEncodable, RustcDecodable, PartialEq, Eq, PartialOrd, Ord)] pub enum UnpackedKind<'tcx> { Lifetime(ty::Region<'tcx>), Type(Ty<'tcx>), @@ -74,17 +74,7 @@ impl<'tcx> UnpackedKind<'tcx> { impl<'tcx> Ord for Kind<'tcx> { fn cmp(&self, other: &Kind) -> Ordering { - match (self.unpack(), other.unpack()) { - (UnpackedKind::Type(_), UnpackedKind::Lifetime(_)) => Ordering::Greater, - - (UnpackedKind::Type(ty1), UnpackedKind::Type(ty2)) => { - ty1.sty.cmp(&ty2.sty) - } - - (UnpackedKind::Lifetime(reg1), UnpackedKind::Lifetime(reg2)) => reg1.cmp(reg2), - - (UnpackedKind::Lifetime(_), UnpackedKind::Type(_)) => Ordering::Less, - } + self.unpack().cmp(&other.unpack()) } }