diff options
| author | toidiu <apoorv@toidiu.com> | 2018-09-09 00:16:57 -0400 |
|---|---|---|
| committer | toidiu <apoorv@toidiu.com> | 2018-09-09 00:16:57 -0400 |
| commit | 7eb0ef049731ddf7d66dfa8dda13ee9a706906ad (patch) | |
| tree | 1611b93e1d5ea9d736e68b217f3f611536d524e9 | |
| parent | 0198a1ea45e29af00d92423aa6d2ac876410c3f9 (diff) | |
| download | rust-7eb0ef049731ddf7d66dfa8dda13ee9a706906ad.tar.gz rust-7eb0ef049731ddf7d66dfa8dda13ee9a706906ad.zip | |
simplify ordering for Kind
| -rw-r--r-- | src/librustc/ty/subst.rs | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/librustc/ty/subst.rs b/src/librustc/ty/subst.rs index b6ffcd55d91..696c4d0043c 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()) } } |
