Use map_bound(_ref) instead of Binder::bind when possible

This commit is contained in:
Jack Huey 2020-10-07 20:02:06 -04:00
parent a78a62fc99
commit dd5c9bf139
24 changed files with 173 additions and 143 deletions

View file

@ -642,7 +642,8 @@ impl AutoTraitFinder<'tcx> {
// We check this by calling is_of_param on the relevant types
// from the various possible predicates
match predicate.skip_binders() {
let bound_predicate = predicate.bound_atom(select.infcx().tcx);
match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(p, _) => {
if self.is_param_no_infer(p.trait_ref.substs)
&& !only_projections
@ -650,10 +651,10 @@ impl AutoTraitFinder<'tcx> {
{
self.add_user_pred(computed_preds, predicate);
}
predicates.push_back(ty::Binder::bind(p));
predicates.push_back(bound_predicate.map_bound_ref(|_| p));
}
ty::PredicateAtom::Projection(p) => {
let p = ty::Binder::bind(p);
let p = bound_predicate.map_bound_ref(|_| p);
debug!(
"evaluate_nested_obligations: examining projection predicate {:?}",
predicate
@ -783,13 +784,13 @@ impl AutoTraitFinder<'tcx> {
}
}
ty::PredicateAtom::RegionOutlives(binder) => {
let binder = ty::Binder::bind(binder);
let binder = bound_predicate.map_bound_ref(|_| binder);
if select.infcx().region_outlives_predicate(&dummy_cause, binder).is_err() {
return false;
}
}
ty::PredicateAtom::TypeOutlives(binder) => {
let binder = ty::Binder::bind(binder);
let binder = bound_predicate.map_bound_ref(|_| binder);
match (
binder.no_bound_vars(),
binder.map_bound_ref(|pred| pred.0).no_bound_vars(),