Skip to content

Commit 7eb0ef0

Browse files
committed
simplify ordering for Kind
1 parent 0198a1e commit 7eb0ef0

File tree

1 file changed

+2
-12
lines changed

1 file changed

+2
-12
lines changed

src/librustc/ty/subst.rs

+2-12
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ const TAG_MASK: usize = 0b11;
4242
const TYPE_TAG: usize = 0b00;
4343
const REGION_TAG: usize = 0b01;
4444

45-
#[derive(Debug, RustcEncodable, RustcDecodable)]
45+
#[derive(Debug, RustcEncodable, RustcDecodable, PartialEq, Eq, PartialOrd, Ord)]
4646
pub enum UnpackedKind<'tcx> {
4747
Lifetime(ty::Region<'tcx>),
4848
Type(Ty<'tcx>),
@@ -74,17 +74,7 @@ impl<'tcx> UnpackedKind<'tcx> {
7474

7575
impl<'tcx> Ord for Kind<'tcx> {
7676
fn cmp(&self, other: &Kind) -> Ordering {
77-
match (self.unpack(), other.unpack()) {
78-
(UnpackedKind::Type(_), UnpackedKind::Lifetime(_)) => Ordering::Greater,
79-
80-
(UnpackedKind::Type(ty1), UnpackedKind::Type(ty2)) => {
81-
ty1.sty.cmp(&ty2.sty)
82-
}
83-
84-
(UnpackedKind::Lifetime(reg1), UnpackedKind::Lifetime(reg2)) => reg1.cmp(reg2),
85-
86-
(UnpackedKind::Lifetime(_), UnpackedKind::Type(_)) => Ordering::Less,
87-
}
77+
self.unpack().cmp(&other.unpack())
8878
}
8979
}
9080

0 commit comments

Comments
 (0)