Skip to content

Commit 3dd830b

Browse files
committed
ptr eq for Predicate
1 parent 6544d7b commit 3dd830b

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/librustc_middle/ty/mod.rs

+15-6
Original file line numberDiff line numberDiff line change
@@ -1016,14 +1016,23 @@ impl<'tcx> GenericPredicates<'tcx> {
10161016
}
10171017
}
10181018

1019-
#[derive(Clone, Copy, PartialEq, Eq, Hash, RustcEncodable, RustcDecodable, Lift)]
1019+
#[derive(Clone, Copy, Hash, RustcEncodable, RustcDecodable, Lift)]
10201020
#[derive(HashStable)]
10211021
pub struct Predicate<'tcx> {
10221022
kind: &'tcx PredicateKind<'tcx>,
10231023
}
10241024

1025-
impl Predicate<'tcx> {
1026-
pub fn kind(&self) -> &'tcx PredicateKind<'tcx> {
1025+
impl<'tcx> PartialEq for Predicate<'tcx> {
1026+
fn eq(&self, other: &Self) -> bool {
1027+
// `self.kind` is always interned.
1028+
ptr::eq(self.kind, other.kind)
1029+
}
1030+
}
1031+
1032+
impl<'tcx> Eq for Predicate<'tcx> {}
1033+
1034+
impl<'tcx> Predicate<'tcx> {
1035+
pub fn kind(self) -> &'tcx PredicateKind<'tcx> {
10271036
self.kind
10281037
}
10291038
}
@@ -1098,7 +1107,7 @@ impl<'tcx> Predicate<'tcx> {
10981107
/// substitution in terms of what happens with bound regions. See
10991108
/// lengthy comment below for details.
11001109
pub fn subst_supertrait(
1101-
&self,
1110+
self,
11021111
tcx: TyCtxt<'tcx>,
11031112
trait_ref: &ty::PolyTraitRef<'tcx>,
11041113
) -> ty::Predicate<'tcx> {
@@ -1369,7 +1378,7 @@ impl<'tcx> ToPredicate<'tcx> for PolyProjectionPredicate<'tcx> {
13691378
}
13701379

13711380
impl<'tcx> Predicate<'tcx> {
1372-
pub fn to_opt_poly_trait_ref(&self) -> Option<PolyTraitRef<'tcx>> {
1381+
pub fn to_opt_poly_trait_ref(self) -> Option<PolyTraitRef<'tcx>> {
13731382
match self.kind() {
13741383
&PredicateKind::Trait(ref t, _) => Some(t.to_poly_trait_ref()),
13751384
PredicateKind::Projection(..)
@@ -1384,7 +1393,7 @@ impl<'tcx> Predicate<'tcx> {
13841393
}
13851394
}
13861395

1387-
pub fn to_opt_type_outlives(&self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
1396+
pub fn to_opt_type_outlives(self) -> Option<PolyTypeOutlivesPredicate<'tcx>> {
13881397
match self.kind() {
13891398
&PredicateKind::TypeOutlives(data) => Some(data),
13901399
PredicateKind::Trait(..)

0 commit comments

Comments
 (0)