@@ -2239,7 +2239,7 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2239
2239
let ocx = ObligationCtxt :: new_in_snapshot ( & infcx) ;
2240
2240
2241
2241
let impl_ty = tcx. type_of ( impl_) ;
2242
- let impl_substs = self . fresh_item_substs ( impl_, & infcx ) ;
2242
+ let impl_substs = infcx . fresh_item_substs ( impl_) ;
2243
2243
let impl_ty = impl_ty. subst ( tcx, impl_substs) ;
2244
2244
let impl_ty = ocx. normalize ( & cause, param_env, impl_ty) ;
2245
2245
@@ -2306,36 +2306,6 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
2306
2306
) )
2307
2307
}
2308
2308
2309
- // FIXME(fmease): Copied from `rustc_hir_typeck::method::probe`. Deduplicate.
2310
- fn fresh_item_substs ( & self , def_id : DefId , infcx : & InferCtxt < ' tcx > ) -> SubstsRef < ' tcx > {
2311
- let tcx = self . tcx ( ) ;
2312
-
2313
- InternalSubsts :: for_item ( tcx, def_id, |param, _| match param. kind {
2314
- GenericParamDefKind :: Lifetime => tcx. lifetimes . re_erased . into ( ) ,
2315
- GenericParamDefKind :: Type { .. } => infcx
2316
- . next_ty_var ( TypeVariableOrigin {
2317
- kind : TypeVariableOriginKind :: SubstitutionPlaceholder ,
2318
- span : tcx. def_span ( def_id) ,
2319
- } )
2320
- . into ( ) ,
2321
- GenericParamDefKind :: Const { .. } => {
2322
- let span = tcx. def_span ( def_id) ;
2323
- let origin = ConstVariableOrigin {
2324
- kind : ConstVariableOriginKind :: SubstitutionPlaceholder ,
2325
- span,
2326
- } ;
2327
- infcx
2328
- . next_const_var (
2329
- tcx. type_of ( param. def_id )
2330
- . no_bound_vars ( )
2331
- . expect ( "const parameter types cannot be generic" ) ,
2332
- origin,
2333
- )
2334
- . into ( )
2335
- }
2336
- } )
2337
- }
2338
-
2339
2309
fn lookup_assoc_ty (
2340
2310
& self ,
2341
2311
name : Ident ,
@@ -3531,3 +3501,36 @@ impl<'o, 'tcx> dyn AstConv<'tcx> + 'o {
3531
3501
}
3532
3502
}
3533
3503
}
3504
+
3505
+ pub trait InferCtxtExt < ' tcx > {
3506
+ fn fresh_item_substs ( & self , def_id : DefId ) -> SubstsRef < ' tcx > ;
3507
+ }
3508
+
3509
+ impl < ' tcx > InferCtxtExt < ' tcx > for InferCtxt < ' tcx > {
3510
+ fn fresh_item_substs ( & self , def_id : DefId ) -> SubstsRef < ' tcx > {
3511
+ InternalSubsts :: for_item ( self . tcx , def_id, |param, _| match param. kind {
3512
+ GenericParamDefKind :: Lifetime => self . tcx . lifetimes . re_erased . into ( ) ,
3513
+ GenericParamDefKind :: Type { .. } => self
3514
+ . next_ty_var ( TypeVariableOrigin {
3515
+ kind : TypeVariableOriginKind :: SubstitutionPlaceholder ,
3516
+ span : self . tcx . def_span ( def_id) ,
3517
+ } )
3518
+ . into ( ) ,
3519
+ GenericParamDefKind :: Const { .. } => {
3520
+ let span = self . tcx . def_span ( def_id) ;
3521
+ let origin = ConstVariableOrigin {
3522
+ kind : ConstVariableOriginKind :: SubstitutionPlaceholder ,
3523
+ span,
3524
+ } ;
3525
+ self . next_const_var (
3526
+ self . tcx
3527
+ . type_of ( param. def_id )
3528
+ . no_bound_vars ( )
3529
+ . expect ( "const parameter types cannot be generic" ) ,
3530
+ origin,
3531
+ )
3532
+ . into ( )
3533
+ }
3534
+ } )
3535
+ }
3536
+ }
0 commit comments