Skip to content

Commit 78d8f6f

Browse files
committed
review
1 parent ded761b commit 78d8f6f

File tree

2 files changed

+18
-38
lines changed

2 files changed

+18
-38
lines changed

src/librustc_infer/traits/util.rs

+14-28
Original file line numberDiff line numberDiff line change
@@ -11,36 +11,22 @@ pub fn anonymize_predicate<'tcx>(
1111
pred: ty::Predicate<'tcx>,
1212
) -> ty::Predicate<'tcx> {
1313
let kind = pred.kind();
14-
let new = match kind {
14+
match kind {
1515
ty::PredicateKind::ForAll(binder) => {
16-
ty::PredicateKind::ForAll(tcx.anonymize_late_bound_regions(binder))
16+
let new = ty::PredicateKind::ForAll(tcx.anonymize_late_bound_regions(binder));
17+
if new != *kind { new.to_predicate(tcx) } else { pred }
1718
}
18-
&ty::PredicateKind::Trait(data, constness) => ty::PredicateKind::Trait(data, constness),
19-
20-
&ty::PredicateKind::RegionOutlives(data) => ty::PredicateKind::RegionOutlives(data),
21-
22-
&ty::PredicateKind::TypeOutlives(data) => ty::PredicateKind::TypeOutlives(data),
23-
24-
&ty::PredicateKind::Projection(data) => ty::PredicateKind::Projection(data),
25-
26-
&ty::PredicateKind::WellFormed(data) => ty::PredicateKind::WellFormed(data),
27-
28-
&ty::PredicateKind::ObjectSafe(data) => ty::PredicateKind::ObjectSafe(data),
29-
30-
&ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind) => {
31-
ty::PredicateKind::ClosureKind(closure_def_id, closure_substs, kind)
32-
}
33-
34-
&ty::PredicateKind::Subtype(data) => ty::PredicateKind::Subtype(data),
35-
36-
&ty::PredicateKind::ConstEvaluatable(def_id, substs) => {
37-
ty::PredicateKind::ConstEvaluatable(def_id, substs)
38-
}
39-
40-
&ty::PredicateKind::ConstEquate(c1, c2) => ty::PredicateKind::ConstEquate(c1, c2),
41-
};
42-
43-
if new != *kind { new.to_predicate(tcx) } else { pred }
19+
ty::PredicateKind::Trait(_, _)
20+
| ty::PredicateKind::RegionOutlives(_)
21+
| ty::PredicateKind::TypeOutlives(_)
22+
| ty::PredicateKind::Projection(_)
23+
| ty::PredicateKind::WellFormed(_)
24+
| ty::PredicateKind::ObjectSafe(_)
25+
| ty::PredicateKind::ClosureKind(_, _, _)
26+
| ty::PredicateKind::Subtype(_)
27+
| ty::PredicateKind::ConstEvaluatable(_, _)
28+
| ty::PredicateKind::ConstEquate(_, _) => pred,
29+
}
4430
}
4531

4632
struct PredicateSet<'tcx> {

src/librustc_middle/ty/mod.rs

+4-10
Original file line numberDiff line numberDiff line change
@@ -1217,17 +1217,11 @@ impl<'tcx> Predicate<'tcx> {
12171217
// substitution code expects equal binding levels in the values
12181218
// from the substitution and the value being substituted into, and
12191219
// this trick achieves that).
1220-
12211220
let substs = trait_ref.skip_binder().substs;
1222-
let kind = match self.kind() {
1223-
PredicateKind::ForAll(binder) => binder.skip_binder().kind(),
1224-
kind => kind,
1225-
};
1226-
1227-
let new = kind.subst(tcx, substs);
1228-
1229-
if new != *kind {
1230-
new.to_predicate(tcx).potentially_qualified(tcx, PredicateKind::ForAll)
1221+
let pred = *self.ignore_qualifiers(tcx).skip_binder();
1222+
let new = pred.subst(tcx, substs);
1223+
if new != pred {
1224+
new.potentially_qualified(tcx, PredicateKind::ForAll)
12311225
} else {
12321226
self
12331227
}

0 commit comments

Comments
 (0)