1
Fork 0

map_bound_ref -> rebind

This commit is contained in:
Jack Huey 2020-10-16 14:04:11 -04:00
parent 11d62aa284
commit eba10270c6
21 changed files with 77 additions and 78 deletions

View file

@ -1098,7 +1098,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
let bound_predicate = obligation.predicate.bound_atom(tcx);
match bound_predicate.skip_binder() {
ty::PredicateAtom::Trait(pred, _) => {
let pred = bound_predicate.map_bound_ref(|_| pred);
let pred = bound_predicate.rebind(pred);
associated_types.entry(span).or_default().extend(
tcx.associated_items(pred.def_id())
.in_definition_order()
@ -1107,7 +1107,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
);
}
ty::PredicateAtom::Projection(pred) => {
let pred = bound_predicate.map_bound_ref(|_| pred);
let pred = bound_predicate.rebind(pred);
// A `Self` within the original bound will be substituted with a
// `trait_object_dummy_self`, so check for that.
let references_self =

View file

@ -200,7 +200,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
// the complete signature.
self.deduce_sig_from_projection(
Some(obligation.cause.span),
bound_predicate.map_bound_ref(|_| proj_predicate),
bound_predicate.rebind(proj_predicate),
)
} else {
None

View file

@ -595,7 +595,7 @@ impl<'f, 'tcx> Coerce<'f, 'tcx> {
has_unsized_tuple_coercion = true;
}
}
bound_predicate.map_bound_ref(|_| trait_pred)
bound_predicate.rebind(trait_pred)
}
_ => {
coercion.obligations.push(obligation);

View file

@ -229,12 +229,12 @@ fn ensure_drop_predicates_are_implied_by_item_defn<'tcx>(
let bound_predicate = predicate.bound_atom(tcx);
let bound_p = p.bound_atom(tcx);
match (predicate.skip_binders(), p.skip_binders()) {
(ty::PredicateAtom::Trait(a, _), ty::PredicateAtom::Trait(b, _)) => relator
.relate(bound_predicate.map_bound_ref(|_| a), bound_p.map_bound_ref(|_| b))
.is_ok(),
(ty::PredicateAtom::Projection(a), ty::PredicateAtom::Projection(b)) => relator
.relate(bound_predicate.map_bound_ref(|_| a), bound_p.map_bound_ref(|_| b))
.is_ok(),
(ty::PredicateAtom::Trait(a, _), ty::PredicateAtom::Trait(b, _)) => {
relator.relate(bound_predicate.rebind(a), bound_p.rebind(b)).is_ok()
}
(ty::PredicateAtom::Projection(a), ty::PredicateAtom::Projection(b)) => {
relator.relate(bound_predicate.rebind(a), bound_p.rebind(b)).is_ok()
}
_ => predicate == p,
}
};

View file

@ -803,7 +803,7 @@ impl<'a, 'tcx> ProbeContext<'a, 'tcx> {
ty::PredicateAtom::Trait(trait_predicate, _) => {
match trait_predicate.trait_ref.self_ty().kind() {
ty::Param(ref p) if *p == param_ty => {
Some(bound_predicate.map_bound_ref(|_| trait_predicate.trait_ref))
Some(bound_predicate.rebind(trait_predicate.trait_ref))
}
_ => None,
}

View file

@ -640,7 +640,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
let bound_predicate = pred.bound_atom(tcx);
match bound_predicate.skip_binder() {
ty::PredicateAtom::Projection(pred) => {
let pred = bound_predicate.map_bound_ref(|_| pred);
let pred = bound_predicate.rebind(pred);
// `<Foo as Iterator>::Item = String`.
let trait_ref =
pred.skip_binder().projection_ty.trait_ref(self.tcx);

View file

@ -862,7 +862,7 @@ fn bounds_from_generic_predicates<'tcx>(
}
}
ty::PredicateAtom::Projection(projection_pred) => {
projections.push(bound_predicate.map_bound_ref(|_| projection_pred));
projections.push(bound_predicate.rebind(projection_pred));
}
_ => {}
}