@@ -382,14 +382,14 @@ impl<'tcx> Instance<'tcx> {
382
382
pub fn resolve_closure (
383
383
tcx : TyCtxt < ' tcx > ,
384
384
def_id : DefId ,
385
- substs : ty:: SubstsRef < ' tcx > ,
385
+ closure_substs : ty:: ClosureSubsts < ' tcx > ,
386
386
requested_kind : ty:: ClosureKind ,
387
387
) -> Instance < ' tcx > {
388
- let actual_kind = substs . as_closure ( ) . kind ( ) ;
388
+ let actual_kind = closure_substs . kind ( ) ;
389
389
390
390
match needs_fn_once_adapter_shim ( actual_kind, requested_kind) {
391
- Ok ( true ) => Instance :: fn_once_adapter_instance ( tcx, def_id, substs ) ,
392
- _ => Instance :: new ( def_id, substs ) ,
391
+ Ok ( true ) => Instance :: fn_once_adapter_instance ( tcx, def_id, closure_substs ) ,
392
+ _ => Instance :: new ( def_id, tcx . intern_substs ( closure_substs . base_substs ( ) ) ) ,
393
393
}
394
394
}
395
395
@@ -399,12 +399,12 @@ impl<'tcx> Instance<'tcx> {
399
399
Instance :: resolve ( tcx, ty:: ParamEnv :: reveal_all ( ) , def_id, substs) . unwrap ( ) . unwrap ( )
400
400
}
401
401
402
- pub fn fn_once_adapter_instance (
402
+ fn fn_once_adapter_instance (
403
403
tcx : TyCtxt < ' tcx > ,
404
404
closure_did : DefId ,
405
- substs : ty:: SubstsRef < ' tcx > ,
405
+ closure_substs : ty:: ClosureSubsts < ' tcx > ,
406
406
) -> Instance < ' tcx > {
407
- debug ! ( "fn_once_adapter_shim({:?}, {:?})" , closure_did, substs ) ;
407
+ debug ! ( "fn_once_adapter_shim({:?}, {:?})" , closure_did, closure_substs ) ;
408
408
let fn_once = tcx. require_lang_item ( FnOnceTraitLangItem , None ) ;
409
409
let call_once = tcx
410
410
. associated_items ( fn_once)
@@ -414,9 +414,9 @@ impl<'tcx> Instance<'tcx> {
414
414
. def_id ;
415
415
let def = ty:: InstanceDef :: ClosureOnceShim { call_once } ;
416
416
417
- let self_ty = tcx. mk_closure ( closure_did, substs) ;
417
+ let self_ty = tcx. mk_closure ( closure_did, closure_substs . substs ) ;
418
418
419
- let sig = substs . as_closure ( ) . sig ( ) ;
419
+ let sig = closure_substs . sig ( ) ;
420
420
let sig = tcx. normalize_erasing_late_bound_regions ( ty:: ParamEnv :: reveal_all ( ) , & sig) ;
421
421
assert_eq ! ( sig. inputs( ) . len( ) , 1 ) ;
422
422
let substs = tcx. mk_substs_trait ( self_ty, & [ sig. inputs ( ) [ 0 ] . into ( ) ] ) ;
0 commit comments