@@ -11,6 +11,7 @@ use super::coherence::{self, Conflict};
11
11
use super :: project;
12
12
use super :: project:: { normalize_with_depth, Normalized , ProjectionCacheKey } ;
13
13
use super :: util;
14
+ use super :: util:: { closure_trait_ref_and_return_type, predicate_for_trait_def} ;
14
15
use super :: DerivedObligationCause ;
15
16
use super :: Selection ;
16
17
use super :: SelectionResult ;
@@ -2651,7 +2652,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2651
2652
recursion_depth,
2652
2653
& skol_ty,
2653
2654
) ;
2654
- let skol_obligation = self . tcx ( ) . predicate_for_trait_def (
2655
+ let skol_obligation = predicate_for_trait_def (
2656
+ self . tcx ( ) ,
2655
2657
param_env,
2656
2658
cause. clone ( ) ,
2657
2659
trait_def_id,
@@ -2988,7 +2990,7 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
2988
2990
// we pass over, we sum up the set of number of vtable
2989
2991
// entries, so that we can compute the offset for the selected
2990
2992
// 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 ( ) ;
2992
2994
}
2993
2995
2994
2996
VtableObjectData { upcast_trait_ref : upcast_trait_ref. unwrap ( ) , vtable_base, nested }
@@ -3003,15 +3005,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
3003
3005
// Okay to skip binder; it is reintroduced below.
3004
3006
let self_ty = self . infcx . shallow_resolve ( * obligation. self_ty ( ) . skip_binder ( ) ) ;
3005
3007
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) ;
3015
3016
3016
3017
let Normalized { value : trait_ref, obligations } = project:: normalize_with_depth (
3017
3018
self ,
@@ -3381,7 +3382,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
3381
3382
nested. extend ( obligations) ;
3382
3383
3383
3384
// 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,
3385
3387
obligation. param_env ,
3386
3388
obligation. cause . clone ( ) ,
3387
3389
obligation. predicate . def_id ( ) ,
@@ -3416,7 +3418,8 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
3416
3418
nested. extend ( obligations) ;
3417
3419
3418
3420
// Construct the nested `T: Unsize<U>` predicate.
3419
- nested. push ( tcx. predicate_for_trait_def (
3421
+ nested. push ( predicate_for_trait_def (
3422
+ tcx,
3420
3423
obligation. param_env ,
3421
3424
obligation. cause . clone ( ) ,
3422
3425
obligation. predicate . def_id ( ) ,
@@ -3627,14 +3630,14 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
3627
3630
// in fact unparameterized (or at least does not reference any
3628
3631
// regions bound in the obligation). Still probably some
3629
3632
// 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)
3638
3641
}
3639
3642
3640
3643
fn generator_trait_ref_unnormalized (
@@ -3651,13 +3654,13 @@ impl<'cx, 'tcx> SelectionContext<'cx, 'tcx> {
3651
3654
// regions bound in the obligation). Still probably some
3652
3655
// refactoring could make this nicer.
3653
3656
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)
3661
3664
}
3662
3665
3663
3666
/// Returns the obligations that are implied by instantiating an
0 commit comments