1
Fork 0

Assert that we don't capture escaping bound vars in Fn trait selection

This commit is contained in:
Michael Goulet 2022-11-24 18:45:02 +00:00
parent 5dfb4b0afa
commit 8927135274
3 changed files with 20 additions and 13 deletions

View file

@ -693,16 +693,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
let gen_sig = substs.as_generator().poly_sig();
// (1) Feels icky to skip the binder here, but OTOH we know
// that the self-type is an generator type and hence is
// NOTE: The self-type is a generator type and hence is
// in fact unparameterized (or at least does not reference any
// regions bound in the obligation). Still probably some
// refactoring could make this nicer.
// regions bound in the obligation).
let self_ty = obligation
.predicate
.self_ty()
.no_bound_vars()
.expect("unboxed closure type should not capture bound vars from the predicate");
let trait_ref = super::util::generator_trait_ref_and_outputs(
self.tcx(),
obligation.predicate.def_id(),
obligation.predicate.skip_binder().self_ty(), // (1)
self_ty,
gen_sig,
)
.map_bound(|(trait_ref, ..)| trait_ref);