@@ -605,8 +605,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
605605 {
606606 debug ! ( ?obligation, "confirm_fn_pointer_candidate" ) ;
607607
608- // Okay to skip binder; it is reintroduced below.
609- let self_ty = self . infcx . shallow_resolve ( obligation. self_ty ( ) . skip_binder ( ) ) ;
608+ let self_ty = self
609+ . infcx
610+ . shallow_resolve ( obligation. self_ty ( ) . no_bound_vars ( ) )
611+ . expect ( "fn pointer should not capture bound vars from predicate" ) ;
610612 let sig = self_ty. fn_sig ( self . tcx ( ) ) ;
611613 let trait_ref = closure_trait_ref_and_return_type (
612614 self . tcx ( ) ,
@@ -621,15 +623,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
621623
622624 // Confirm the `type Output: Sized;` bound that is present on `FnOnce`
623625 let cause = obligation. derived_cause ( BuiltinDerivedObligation ) ;
624- // The binder on the Fn obligation is "less" important than the one on
625- // the signature, as evidenced by how we treat it during projection.
626- // The safe thing to do here is to liberate it, though, which should
627- // have no worse effect than skipping the binder here.
628- let liberated_fn_ty =
629- self . infcx . replace_bound_vars_with_placeholders ( obligation. predicate . rebind ( self_ty) ) ;
630- let output_ty = self
631- . infcx
632- . replace_bound_vars_with_placeholders ( liberated_fn_ty. fn_sig ( self . tcx ( ) ) . output ( ) ) ;
626+ let output_ty = self . infcx . replace_bound_vars_with_placeholders ( sig. output ( ) ) ;
633627 let output_ty = normalize_with_depth_to (
634628 self ,
635629 obligation. param_env ,
@@ -693,16 +687,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
693687
694688 let gen_sig = substs. as_generator ( ) . poly_sig ( ) ;
695689
696- // (1) Feels icky to skip the binder here, but OTOH we know
697- // that the self-type is an generator type and hence is
690+ // NOTE: The self-type is a generator type and hence is
698691 // in fact unparameterized (or at least does not reference any
699- // regions bound in the obligation). Still probably some
700- // refactoring could make this nicer.
692+ // regions bound in the obligation).
693+ let self_ty = obligation
694+ . predicate
695+ . self_ty ( )
696+ . no_bound_vars ( )
697+ . expect ( "unboxed closure type should not capture bound vars from the predicate" ) ;
701698
702699 let trait_ref = super :: util:: generator_trait_ref_and_outputs (
703700 self . tcx ( ) ,
704701 obligation. predicate . def_id ( ) ,
705- obligation . predicate . skip_binder ( ) . self_ty ( ) , // (1)
702+ self_ty,
706703 gen_sig,
707704 )
708705 . map_bound ( |( trait_ref, ..) | trait_ref) ;
0 commit comments