@@ -605,8 +605,10 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
605
605
{
606
606
debug ! ( ?obligation, "confirm_fn_pointer_candidate" ) ;
607
607
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" ) ;
610
612
let sig = self_ty. fn_sig ( self . tcx ( ) ) ;
611
613
let trait_ref = closure_trait_ref_and_return_type (
612
614
self . tcx ( ) ,
@@ -621,15 +623,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
621
623
622
624
// Confirm the `type Output: Sized;` bound that is present on `FnOnce`
623
625
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 ( ) ) ;
633
627
let output_ty = normalize_with_depth_to (
634
628
self ,
635
629
obligation. param_env ,
@@ -693,16 +687,19 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
693
687
694
688
let gen_sig = substs. as_generator ( ) . poly_sig ( ) ;
695
689
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
698
691
// 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" ) ;
701
698
702
699
let trait_ref = super :: util:: generator_trait_ref_and_outputs (
703
700
self . tcx ( ) ,
704
701
obligation. predicate . def_id ( ) ,
705
- obligation . predicate . skip_binder ( ) . self_ty ( ) , // (1)
702
+ self_ty,
706
703
gen_sig,
707
704
)
708
705
. map_bound ( |( trait_ref, ..) | trait_ref) ;
0 commit comments