1
Fork 0

Rollup merge of #89001 - jackh726:binder-cleanup, r=nikomatsakis

Be explicit about using Binder::dummy

This is somewhat of a late followup to the binder refactor PR. It removes `ToPredicate` and `ToPolyTraitImpls` that hide the use of `Binder::dummy`. While this does make code a bit more verbose, it allows us be more careful about where we create binders.

Another alternative here might be to add a new trait `ToBinder` or something with a `dummy()` fn. Which could still allow grepping but allows doing something like `trait_ref.dummy()` (but I also wonder if longer-term, it would be better to be even more explicit with a `bind_with_vars(ty::List::empty())` *but* that's not clear yet.

r? ``@nikomatsakis``
This commit is contained in:
Jubilee 2021-09-24 11:40:11 -07:00 committed by GitHub
commit ee2e97c416
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
34 changed files with 127 additions and 121 deletions

View file

@ -669,8 +669,10 @@ impl<'tcx> TypeRelatingDelegate<'tcx> for QueryTypeRelatingDelegate<'_, 'tcx> {
self.obligations.push(Obligation {
cause: self.cause.clone(),
param_env: self.param_env,
predicate: ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(sup, sub))
.to_predicate(self.infcx.tcx),
predicate: ty::Binder::dummy(ty::PredicateKind::RegionOutlives(ty::OutlivesPredicate(
sup, sub,
)))
.to_predicate(self.infcx.tcx),
recursion_depth: 0,
});
}

View file

@ -360,7 +360,8 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
self.obligations.push(Obligation::new(
self.trace.cause.clone(),
self.param_env,
ty::PredicateKind::WellFormed(b_ty.into()).to_predicate(self.infcx.tcx),
ty::Binder::dummy(ty::PredicateKind::WellFormed(b_ty.into()))
.to_predicate(self.infcx.tcx),
));
}
@ -463,7 +464,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
self.obligations.push(Obligation::new(
self.trace.cause.clone(),
self.param_env,
predicate.to_predicate(self.tcx()),
ty::Binder::dummy(predicate).to_predicate(self.tcx()),
));
}
}

View file

@ -97,11 +97,11 @@ impl TypeRelation<'tcx> for Sub<'combine, 'infcx, 'tcx> {
self.fields.obligations.push(Obligation::new(
self.fields.trace.cause.clone(),
self.fields.param_env,
ty::PredicateKind::Subtype(ty::SubtypePredicate {
ty::Binder::dummy(ty::PredicateKind::Subtype(ty::SubtypePredicate {
a_is_expected: self.a_is_expected,
a,
b,
})
}))
.to_predicate(self.tcx()),
));

View file

@ -35,7 +35,7 @@ pub trait TraitEngine<'tcx>: 'tcx {
cause,
recursion_depth: 0,
param_env,
predicate: trait_ref.without_const().to_predicate(infcx.tcx),
predicate: ty::Binder::dummy(trait_ref).without_const().to_predicate(infcx.tcx),
},
);
}

View file

@ -231,6 +231,7 @@ impl Elaborator<'tcx> {
None
}
})
.map(ty::Binder::dummy)
.map(|predicate_kind| predicate_kind.to_predicate(tcx))
.filter(|&predicate| visited.insert(predicate))
.map(|predicate| {