mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-02 07:22:42 +00:00
map_bound_ref -> rebind
This commit is contained in:
parent
11d62aa284
commit
eba10270c6
@ -551,8 +551,7 @@ impl TypeRelation<'tcx> for Generalizer<'_, 'tcx> {
|
||||
where
|
||||
T: Relate<'tcx>,
|
||||
{
|
||||
let result = self.relate(a.skip_binder(), b.skip_binder())?;
|
||||
Ok(a.map_bound(|_| result))
|
||||
Ok(ty::Binder::bind(self.relate(a.skip_binder(), b.skip_binder())?))
|
||||
}
|
||||
|
||||
fn relate_item_substs(
|
||||
@ -834,8 +833,7 @@ impl TypeRelation<'tcx> for ConstInferUnifier<'_, 'tcx> {
|
||||
where
|
||||
T: Relate<'tcx>,
|
||||
{
|
||||
let result = self.relate(a.skip_binder(), b.skip_binder())?;
|
||||
Ok(a.map_bound(|_| result))
|
||||
Ok(ty::Binder::bind(self.relate(a.skip_binder(), b.skip_binder())?))
|
||||
}
|
||||
|
||||
fn tys(&mut self, t: Ty<'tcx>, _t: Ty<'tcx>) -> RelateResult<'tcx, Ty<'tcx>> {
|
||||
|
@ -1004,6 +1004,6 @@ where
|
||||
self.first_free_index.shift_in(1);
|
||||
let result = self.relate(a.skip_binder(), a.skip_binder())?;
|
||||
self.first_free_index.shift_out(1);
|
||||
Ok(a.map_bound(|_| result))
|
||||
Ok(ty::Binder::bind(result))
|
||||
}
|
||||
}
|
||||
|
@ -134,7 +134,7 @@ impl Elaborator<'tcx> {
|
||||
|
||||
let obligations = predicates.predicates.iter().map(|&(pred, _)| {
|
||||
predicate_obligation(
|
||||
pred.subst_supertrait(tcx, &bound_predicate.map_bound(|_| data.trait_ref)),
|
||||
pred.subst_supertrait(tcx, &bound_predicate.rebind(data.trait_ref)),
|
||||
obligation.param_env,
|
||||
obligation.cause.clone(),
|
||||
)
|
||||
|
@ -118,7 +118,6 @@ impl TypeRelation<'tcx> for Match<'tcx> {
|
||||
where
|
||||
T: Relate<'tcx>,
|
||||
{
|
||||
let result = self.relate(a.skip_binder(), b.skip_binder())?;
|
||||
Ok(a.map_bound(|_| result))
|
||||
Ok(ty::Binder::bind(self.relate(a.skip_binder(), b.skip_binder())?))
|
||||
}
|
||||
}
|
||||
|
@ -620,7 +620,7 @@ pub trait PrettyPrinter<'tcx>:
|
||||
// FIXME(lcnr): Find out why exactly this is the case :)
|
||||
let bound_predicate = predicate.bound_atom_with_opt_escaping(self.tcx());
|
||||
if let ty::PredicateAtom::Trait(pred, _) = bound_predicate.skip_binder() {
|
||||
let trait_ref = bound_predicate.map_bound(|_| pred.trait_ref);
|
||||
let trait_ref = bound_predicate.rebind(pred.trait_ref);
|
||||
// Don't print +Sized, but rather +?Sized if absent.
|
||||
if Some(trait_ref.def_id()) == self.tcx().lang_items().sized_trait() {
|
||||
is_sized = true;
|
||||
|
@ -549,7 +549,7 @@ impl<'a, 'tcx> Lift<'tcx> for ty::PredicateAtom<'a> {
|
||||
impl<'tcx, T: Lift<'tcx>> Lift<'tcx> for ty::Binder<T> {
|
||||
type Lifted = ty::Binder<T::Lifted>;
|
||||
fn lift_to_tcx(&self, tcx: TyCtxt<'tcx>) -> Option<Self::Lifted> {
|
||||
tcx.lift(self.as_ref().skip_binder()).map(|v| self.map_bound_ref(|_| v))
|
||||
tcx.lift(self.as_ref().skip_binder()).map(|v| self.rebind(v))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -702,16 +702,14 @@ impl<'tcx> Binder<ExistentialPredicate<'tcx>> {
|
||||
pub fn with_self_ty(&self, tcx: TyCtxt<'tcx>, self_ty: Ty<'tcx>) -> ty::Predicate<'tcx> {
|
||||
use crate::ty::ToPredicate;
|
||||
match self.skip_binder() {
|
||||
ExistentialPredicate::Trait(tr) => self
|
||||
.map_bound_ref(|_| tr)
|
||||
.with_self_ty(tcx, self_ty)
|
||||
.without_const()
|
||||
.to_predicate(tcx),
|
||||
ExistentialPredicate::Trait(tr) => {
|
||||
self.rebind(tr).with_self_ty(tcx, self_ty).without_const().to_predicate(tcx)
|
||||
}
|
||||
ExistentialPredicate::Projection(p) => {
|
||||
self.map_bound_ref(|_| p.with_self_ty(tcx, self_ty)).to_predicate(tcx)
|
||||
self.rebind(p.with_self_ty(tcx, self_ty)).to_predicate(tcx)
|
||||
}
|
||||
ExistentialPredicate::AutoTrait(did) => {
|
||||
let trait_ref = self.map_bound_ref(|_| ty::TraitRef {
|
||||
let trait_ref = self.rebind(ty::TraitRef {
|
||||
def_id: did,
|
||||
substs: tcx.mk_substs_trait(self_ty, &[]),
|
||||
});
|
||||
@ -779,7 +777,7 @@ impl<'tcx> List<ExistentialPredicate<'tcx>> {
|
||||
|
||||
impl<'tcx> Binder<&'tcx List<ExistentialPredicate<'tcx>>> {
|
||||
pub fn principal(&self) -> Option<ty::Binder<ExistentialTraitRef<'tcx>>> {
|
||||
self.map_bound_ref(|b| b.principal()).transpose()
|
||||
self.map_bound(|b| b.principal()).transpose()
|
||||
}
|
||||
|
||||
pub fn principal_def_id(&self) -> Option<DefId> {
|
||||
@ -1004,6 +1002,14 @@ impl<T> Binder<T> {
|
||||
Binder(f(self.0))
|
||||
}
|
||||
|
||||
/// Wraps a `value` in a binder, using the same bound variables as the
|
||||
/// current `Binder`. This should not be used if the new value *changes*
|
||||
/// the bound variables. Note: the (old or new) value itself does not
|
||||
/// necessarily need to *name* all the bound variables.
|
||||
pub fn rebind<U>(&self, value: U) -> Binder<U> {
|
||||
Binder(value)
|
||||
}
|
||||
|
||||
/// Unwraps and returns the value within, but only if it contains
|
||||
/// no bound vars at all. (In other words, if this binder --
|
||||
/// and indeed any enclosing binder -- doesn't bind anything at
|
||||
|
@ -651,10 +651,10 @@ impl AutoTraitFinder<'tcx> {
|
||||
{
|
||||
self.add_user_pred(computed_preds, predicate);
|
||||
}
|
||||
predicates.push_back(bound_predicate.map_bound_ref(|_| p));
|
||||
predicates.push_back(bound_predicate.rebind(p));
|
||||
}
|
||||
ty::PredicateAtom::Projection(p) => {
|
||||
let p = bound_predicate.map_bound_ref(|_| p);
|
||||
let p = bound_predicate.rebind(p);
|
||||
debug!(
|
||||
"evaluate_nested_obligations: examining projection predicate {:?}",
|
||||
predicate
|
||||
@ -784,13 +784,13 @@ impl AutoTraitFinder<'tcx> {
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::RegionOutlives(binder) => {
|
||||
let binder = bound_predicate.map_bound_ref(|_| binder);
|
||||
let binder = bound_predicate.rebind(binder);
|
||||
if select.infcx().region_outlives_predicate(&dummy_cause, binder).is_err() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
ty::PredicateAtom::TypeOutlives(binder) => {
|
||||
let binder = bound_predicate.map_bound_ref(|_| binder);
|
||||
let binder = bound_predicate.rebind(binder);
|
||||
match (
|
||||
binder.no_bound_vars(),
|
||||
binder.map_bound_ref(|pred| pred.0).no_bound_vars(),
|
||||
|
@ -258,7 +258,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
let bound_predicate = obligation.predicate.bound_atom(self.tcx);
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(trait_predicate, _) => {
|
||||
let trait_predicate = bound_predicate.map_bound_ref(|_| trait_predicate);
|
||||
let trait_predicate = bound_predicate.rebind(trait_predicate);
|
||||
let trait_predicate = self.resolve_vars_if_possible(&trait_predicate);
|
||||
|
||||
if self.tcx.sess.has_errors() && trait_predicate.references_error() {
|
||||
@ -532,7 +532,7 @@ impl<'a, 'tcx> InferCtxtExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
}
|
||||
|
||||
ty::PredicateAtom::RegionOutlives(predicate) => {
|
||||
let predicate = bound_predicate.map_bound_ref(|_| predicate);
|
||||
let predicate = bound_predicate.rebind(predicate);
|
||||
let predicate = self.resolve_vars_if_possible(&predicate);
|
||||
let err = self
|
||||
.region_outlives_predicate(&obligation.cause, predicate)
|
||||
@ -1082,7 +1082,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
let bound_error = error.bound_atom(self.tcx);
|
||||
let (cond, error) = match (cond.skip_binders(), bound_error.skip_binder()) {
|
||||
(ty::PredicateAtom::Trait(..), ty::PredicateAtom::Trait(error, _)) => {
|
||||
(cond, bound_error.map_bound_ref(|_| error))
|
||||
(cond, bound_error.rebind(error))
|
||||
}
|
||||
_ => {
|
||||
// FIXME: make this work in other cases too.
|
||||
@ -1094,7 +1094,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
let bound_predicate = obligation.predicate.bound_atom(self.tcx);
|
||||
if let ty::PredicateAtom::Trait(implication, _) = bound_predicate.skip_binder() {
|
||||
let error = error.to_poly_trait_ref();
|
||||
let implication = bound_predicate.map_bound_ref(|_| implication.trait_ref);
|
||||
let implication = bound_predicate.rebind(implication.trait_ref);
|
||||
// FIXME: I'm just not taking associated types at all here.
|
||||
// Eventually I'll need to implement param-env-aware
|
||||
// `Γ₁ ⊦ φ₁ => Γ₂ ⊦ φ₂` logic.
|
||||
@ -1178,7 +1178,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
let (data, _) = self.replace_bound_vars_with_fresh_vars(
|
||||
obligation.cause.span,
|
||||
infer::LateBoundRegionConversionTime::HigherRankedType,
|
||||
&bound_predicate.map_bound_ref(|_| data),
|
||||
&bound_predicate.rebind(data),
|
||||
);
|
||||
let mut obligations = vec![];
|
||||
let normalized_ty = super::normalize_projection_type(
|
||||
@ -1463,7 +1463,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
let mut err = match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(data, _) => {
|
||||
let self_ty = data.trait_ref.self_ty();
|
||||
let trait_ref = bound_predicate.map_bound_ref(|_| data.trait_ref);
|
||||
let trait_ref = bound_predicate.rebind(data.trait_ref);
|
||||
debug!("self_ty {:?} {:?} trait_ref {:?}", self_ty, self_ty.kind(), trait_ref);
|
||||
|
||||
if predicate.references_error() {
|
||||
@ -1587,7 +1587,7 @@ impl<'a, 'tcx> InferCtxtPrivExt<'tcx> for InferCtxt<'a, 'tcx> {
|
||||
self.emit_inference_failure_err(body_id, span, a.into(), ErrorCode::E0282)
|
||||
}
|
||||
ty::PredicateAtom::Projection(data) => {
|
||||
let trait_ref = bound_predicate.map_bound_ref(|_| data).to_poly_trait_ref(self.tcx);
|
||||
let trait_ref = bound_predicate.rebind(data).to_poly_trait_ref(self.tcx);
|
||||
let self_ty = trait_ref.skip_binder().self_ty();
|
||||
let ty = data.ty;
|
||||
if predicate.references_error() {
|
||||
|
@ -353,7 +353,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
// This means we need to pass it the bound version of our
|
||||
// predicate.
|
||||
ty::PredicateAtom::Trait(trait_ref, _constness) => {
|
||||
let trait_obligation = obligation.with(binder.map_bound_ref(|_| trait_ref));
|
||||
let trait_obligation = obligation.with(binder.rebind(trait_ref));
|
||||
|
||||
self.process_trait_obligation(
|
||||
obligation,
|
||||
@ -362,7 +362,7 @@ impl<'a, 'b, 'tcx> FulfillProcessor<'a, 'b, 'tcx> {
|
||||
)
|
||||
}
|
||||
ty::PredicateAtom::Projection(data) => {
|
||||
let project_obligation = obligation.with(binder.map_bound_ref(|_| data));
|
||||
let project_obligation = obligation.with(binder.rebind(data));
|
||||
|
||||
self.process_projection_obligation(
|
||||
project_obligation,
|
||||
|
@ -634,9 +634,9 @@ fn prune_cache_value_obligations<'a, 'tcx>(
|
||||
// indirect obligations (e.g., we project to `?0`,
|
||||
// but we have `T: Foo<X = ?1>` and `?1: Bar<X =
|
||||
// ?0>`).
|
||||
ty::PredicateAtom::Projection(data) => infcx
|
||||
.unresolved_type_vars(&bound_predicate.map_bound_ref(|_| data.ty))
|
||||
.is_some(),
|
||||
ty::PredicateAtom::Projection(data) => {
|
||||
infcx.unresolved_type_vars(&bound_predicate.rebind(data.ty)).is_some()
|
||||
}
|
||||
|
||||
// We are only interested in `T: Foo<X = U>` predicates, whre
|
||||
// `U` references one of `unresolved_type_vars`. =)
|
||||
@ -910,7 +910,7 @@ fn assemble_candidates_from_predicates<'cx, 'tcx>(
|
||||
debug!(?predicate);
|
||||
let bound_predicate = predicate.bound_atom(infcx.tcx);
|
||||
if let ty::PredicateAtom::Projection(data) = predicate.skip_binders() {
|
||||
let data = bound_predicate.map_bound_ref(|_| data);
|
||||
let data = bound_predicate.rebind(data);
|
||||
let same_def_id = data.projection_def_id() == obligation.predicate.item_def_id;
|
||||
|
||||
let is_match = same_def_id
|
||||
|
@ -449,17 +449,18 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
let result = ensure_sufficient_stack(|| {
|
||||
let bound_predicate = obligation.predicate.bound_atom(self.infcx().tcx);
|
||||
let bound_predicate =
|
||||
obligation.predicate.bound_atom_with_opt_escaping(self.infcx().tcx);
|
||||
match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(t, _) => {
|
||||
let t = bound_predicate.map_bound_ref(|_| t);
|
||||
let t = bound_predicate.rebind(t);
|
||||
debug_assert!(!t.has_escaping_bound_vars());
|
||||
let obligation = obligation.with(t);
|
||||
self.evaluate_trait_predicate_recursively(previous_stack, obligation)
|
||||
}
|
||||
|
||||
ty::PredicateAtom::Subtype(p) => {
|
||||
let p = bound_predicate.map_bound_ref(|_| p);
|
||||
let p = bound_predicate.rebind(p);
|
||||
// Does this code ever run?
|
||||
match self.infcx.subtype_predicate(&obligation.cause, obligation.param_env, p) {
|
||||
Some(Ok(InferOk { mut obligations, .. })) => {
|
||||
@ -503,7 +504,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
}
|
||||
|
||||
ty::PredicateAtom::Projection(data) => {
|
||||
let data = bound_predicate.map_bound_ref(|_| data);
|
||||
let data = bound_predicate.rebind(data);
|
||||
let project_obligation = obligation.with(data);
|
||||
match project::poly_project_and_unify_type(self, &project_obligation) {
|
||||
Ok(Ok(Some(mut subobligations))) => {
|
||||
@ -1177,7 +1178,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
.filter_map(|(idx, bound)| {
|
||||
let bound_predicate = bound.bound_atom(self.infcx.tcx);
|
||||
if let ty::PredicateAtom::Trait(pred, _) = bound_predicate.skip_binder() {
|
||||
let bound = bound_predicate.map_bound_ref(|_| pred.trait_ref);
|
||||
let bound = bound_predicate.rebind(pred.trait_ref);
|
||||
if self.infcx.probe(|_| {
|
||||
match self.match_projection(
|
||||
obligation,
|
||||
@ -1534,15 +1535,17 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
ty::Tuple(tys) => Where(
|
||||
obligation
|
||||
.predicate
|
||||
.map_bound_ref(|_| tys.last().into_iter().map(|k| k.expect_ty()).collect()),
|
||||
.rebind(tys.last().into_iter().map(|k| k.expect_ty()).collect()),
|
||||
),
|
||||
|
||||
ty::Adt(def, substs) => {
|
||||
let sized_crit = def.sized_constraint(self.tcx());
|
||||
// (*) binder moved here
|
||||
Where(obligation.predicate.map_bound_ref(|_| {
|
||||
sized_crit.iter().map(|ty| ty.subst(self.tcx(), substs)).collect()
|
||||
}))
|
||||
Where(
|
||||
obligation.predicate.rebind({
|
||||
sized_crit.iter().map(|ty| ty.subst(self.tcx(), substs)).collect()
|
||||
}),
|
||||
)
|
||||
}
|
||||
|
||||
ty::Projection(_) | ty::Param(_) | ty::Opaque(..) => None,
|
||||
@ -1594,16 +1597,12 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
|
||||
ty::Array(element_ty, _) => {
|
||||
// (*) binder moved here
|
||||
Where(obligation.predicate.map_bound_ref(|_| vec![*element_ty]))
|
||||
Where(obligation.predicate.rebind(vec![*element_ty]))
|
||||
}
|
||||
|
||||
ty::Tuple(tys) => {
|
||||
// (*) binder moved here
|
||||
Where(
|
||||
obligation
|
||||
.predicate
|
||||
.map_bound_ref(|_| tys.iter().map(|k| k.expect_ty()).collect()),
|
||||
)
|
||||
Where(obligation.predicate.rebind(tys.iter().map(|k| k.expect_ty()).collect()))
|
||||
}
|
||||
|
||||
ty::Closure(_, substs) => {
|
||||
@ -1613,11 +1612,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
|
||||
// Not yet resolved.
|
||||
Ambiguous
|
||||
} else {
|
||||
Where(
|
||||
obligation
|
||||
.predicate
|
||||
.map_bound_ref(|_| substs.as_closure().upvar_tys().collect()),
|
||||
)
|
||||
Where(obligation.predicate.rebind(substs.as_closure().upvar_tys().collect()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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 =
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -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,
|
||||
}
|
||||
};
|
||||
|
@ -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,
|
||||
}
|
||||
|
@ -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);
|
||||
|
@ -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));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -317,14 +317,12 @@ impl<'a, 'tcx> AutoTraitFinder<'a, 'tcx> {
|
||||
) -> FxHashSet<GenericParamDef> {
|
||||
let bound_predicate = pred.bound_atom(tcx);
|
||||
let regions = match bound_predicate.skip_binder() {
|
||||
ty::PredicateAtom::Trait(poly_trait_pred, _) => tcx
|
||||
.collect_referenced_late_bound_regions(
|
||||
&bound_predicate.map_bound_ref(|_| poly_trait_pred),
|
||||
),
|
||||
ty::PredicateAtom::Projection(poly_proj_pred) => tcx
|
||||
.collect_referenced_late_bound_regions(
|
||||
&bound_predicate.map_bound_ref(|_| poly_proj_pred),
|
||||
),
|
||||
ty::PredicateAtom::Trait(poly_trait_pred, _) => {
|
||||
tcx.collect_referenced_late_bound_regions(&bound_predicate.rebind(poly_trait_pred))
|
||||
}
|
||||
ty::PredicateAtom::Projection(poly_proj_pred) => {
|
||||
tcx.collect_referenced_late_bound_regions(&bound_predicate.rebind(poly_proj_pred))
|
||||
}
|
||||
_ => return FxHashSet::default(),
|
||||
};
|
||||
|
||||
|
@ -1689,7 +1689,10 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||
.filter_map(|bound| {
|
||||
// Note: The substs of opaque types can contain unbound variables,
|
||||
// meaning that we have to use `ignore_quantifiers_with_unbound_vars` here.
|
||||
let trait_ref = match bound.bound_atom(cx.tcx).skip_binder() {
|
||||
let trait_ref = match bound
|
||||
.bound_atom_with_opt_escaping(cx.tcx)
|
||||
.skip_binder()
|
||||
{
|
||||
ty::PredicateAtom::Trait(tr, _constness) => {
|
||||
ty::Binder::bind(tr.trait_ref)
|
||||
}
|
||||
@ -1713,7 +1716,7 @@ impl<'tcx> Clean<Type> for Ty<'tcx> {
|
||||
.iter()
|
||||
.filter_map(|bound| {
|
||||
if let ty::PredicateAtom::Projection(proj) =
|
||||
bound.bound_atom(cx.tcx).skip_binder()
|
||||
bound.bound_atom_with_opt_escaping(cx.tcx).skip_binder()
|
||||
{
|
||||
if proj.projection_ty.trait_ref(cx.tcx)
|
||||
== trait_ref.skip_binder()
|
||||
|
Loading…
Reference in New Issue
Block a user