@@ -11,6 +11,7 @@ use super::coherence::{self, Conflict};
1111use super :: project;
1212use super :: project:: { normalize_with_depth, Normalized , ProjectionCacheKey } ;
1313use super :: util;
14+ use super :: util:: { closure_trait_ref_and_return_type, predicate_for_trait_def} ;
1415use super :: DerivedObligationCause ;
1516use super :: Selection ;
1617use super :: SelectionResult ;
@@ -2651,7 +2652,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
26512652 recursion_depth,
26522653 & skol_ty,
26532654 ) ;
2654- let skol_obligation = self . tcx ( ) . predicate_for_trait_def (
2655+ let skol_obligation = predicate_for_trait_def (
2656+ self . tcx ( ) ,
26552657 param_env,
26562658 cause. clone ( ) ,
26572659 trait_def_id,
@@ -2988,7 +2990,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
29882990 // we pass over, we sum up the set of number of vtable
29892991 // entries, so that we can compute the offset for the selected
29902992 // trait.
2991- vtable_base = nonmatching. map ( |t| tcx . count_own_vtable_entries ( t) ) . sum ( ) ;
2993+ vtable_base = nonmatching. map ( |t| super :: util :: count_own_vtable_entries ( tcx , t) ) . sum ( ) ;
29922994 }
29932995
29942996 VtableObjectData { upcast_trait_ref : upcast_trait_ref. unwrap ( ) , vtable_base, nested }
@@ -3003,15 +3005,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
30033005 // Okay to skip binder; it is reintroduced below.
30043006 let self_ty = self . infcx . shallow_resolve ( * obligation. self_ty ( ) . skip_binder ( ) ) ;
30053007 let sig = self_ty. fn_sig ( self . tcx ( ) ) ;
3006- let trait_ref = self
3007- . tcx ( )
3008- . closure_trait_ref_and_return_type (
3009- obligation. predicate . def_id ( ) ,
3010- self_ty,
3011- sig,
3012- util:: TupleArgumentsFlag :: Yes ,
3013- )
3014- . map_bound ( |( trait_ref, _) | trait_ref) ;
3008+ let trait_ref = closure_trait_ref_and_return_type (
3009+ self . tcx ( ) ,
3010+ obligation. predicate . def_id ( ) ,
3011+ self_ty,
3012+ sig,
3013+ util:: TupleArgumentsFlag :: Yes ,
3014+ )
3015+ . map_bound ( |( trait_ref, _) | trait_ref) ;
30153016
30163017 let Normalized { value : trait_ref, obligations } = project:: normalize_with_depth (
30173018 self ,
@@ -3381,7 +3382,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
33813382 nested. extend ( obligations) ;
33823383
33833384 // Construct the nested `Field<T>: Unsize<Field<U>>` predicate.
3384- nested. push ( tcx. predicate_for_trait_def (
3385+ nested. push ( predicate_for_trait_def (
3386+ tcx,
33853387 obligation. param_env ,
33863388 obligation. cause . clone ( ) ,
33873389 obligation. predicate . def_id ( ) ,
@@ -3416,7 +3418,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
34163418 nested. extend ( obligations) ;
34173419
34183420 // Construct the nested `T: Unsize<U>` predicate.
3419- nested. push ( tcx. predicate_for_trait_def (
3421+ nested. push ( predicate_for_trait_def (
3422+ tcx,
34203423 obligation. param_env ,
34213424 obligation. cause . clone ( ) ,
34223425 obligation. predicate . def_id ( ) ,
@@ -3627,14 +3630,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
36273630 // in fact unparameterized (or at least does not reference any
36283631 // regions bound in the obligation). Still probably some
36293632 // refactoring could make this nicer.
3630- self . tcx ( )
3631- . closure_trait_ref_and_return_type (
3632- obligation. predicate . def_id ( ) ,
3633- obligation. predicate . skip_binder ( ) . self_ty ( ) , // (1)
3634- closure_type,
3635- util:: TupleArgumentsFlag :: No ,
3636- )
3637- . map_bound ( |( trait_ref, _) | trait_ref)
3633+ closure_trait_ref_and_return_type (
3634+ self . tcx ( ) ,
3635+ obligation. predicate . def_id ( ) ,
3636+ obligation. predicate . skip_binder ( ) . self_ty ( ) , // (1)
3637+ closure_type,
3638+ util:: TupleArgumentsFlag :: No ,
3639+ )
3640+ . map_bound ( |( trait_ref, _) | trait_ref)
36383641 }
36393642
36403643 fn generator_trait_ref_unnormalized (
@@ -3651,13 +3654,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
36513654 // regions bound in the obligation). Still probably some
36523655 // refactoring could make this nicer.
36533656
3654- self . tcx ( )
3655- . generator_trait_ref_and_outputs (
3656- obligation. predicate . def_id ( ) ,
3657- obligation. predicate . skip_binder ( ) . self_ty ( ) , // (1)
3658- gen_sig,
3659- )
3660- . map_bound ( |( trait_ref, ..) | trait_ref)
3657+ super :: util :: generator_trait_ref_and_outputs (
3658+ self . tcx ( ) ,
3659+ obligation. predicate . def_id ( ) ,
3660+ obligation. predicate . skip_binder ( ) . self_ty ( ) , // (1)
3661+ gen_sig,
3662+ )
3663+ . map_bound ( |( trait_ref, ..) | trait_ref)
36613664 }
36623665
36633666 /// Returns the obligations that are implied by instantiating an
0 commit comments