Skip to content

Commit

Permalink
Rollup merge of rust-lang#54074 - toidiu:ak-spimplifyOrd, r=eddyb
Browse files Browse the repository at this point in the history
simplify ordering for Kind

Missed from rust-lang#50930

r? @eddyb
  • Loading branch information
kennytm committed Sep 12, 2018
2 parents 61fe064 + 7eb0ef0 commit 74b8188
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/librustc/ty/subst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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>),
Expand Down Expand Up @@ -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())
}
}

Expand Down

0 comments on commit 74b8188

Please sign in to comment.