@@ -632,27 +632,26 @@ impl<'blk, 'tcx> ty::UnboxedClosureTyper<'tcx> for BlockS<'blk, 'tcx> {
632632 def_id : ast:: DefId )
633633 -> ty:: UnboxedClosureKind
634634 {
635- self . tcx ( ) . unboxed_closure_kind ( def_id)
635+ let typer = NormalizingUnboxedClosureTyper :: new ( self . tcx ( ) ) ;
636+ typer. unboxed_closure_kind ( def_id)
636637 }
637638
638639 fn unboxed_closure_type ( & self ,
639640 def_id : ast:: DefId ,
640641 substs : & subst:: Substs < ' tcx > )
641642 -> ty:: ClosureTy < ' tcx >
642643 {
643- // the substitutions in `substs` are already monomorphized, so we can
644- // ignore `param_substs`
645- self . tcx ( ) . unboxed_closure_type ( def_id, substs)
644+ let typer = NormalizingUnboxedClosureTyper :: new ( self . tcx ( ) ) ;
645+ typer. unboxed_closure_type ( def_id, substs)
646646 }
647647
648648 fn unboxed_closure_upvars ( & self ,
649649 def_id : ast:: DefId ,
650650 substs : & Substs < ' tcx > )
651651 -> Option < Vec < ty:: UnboxedClosureUpvar < ' tcx > > >
652652 {
653- // the substitutions in `substs` are already monomorphized, so we can
654- // ignore `param_substs`
655- ty:: unboxed_closure_upvars ( self . tcx ( ) , def_id, substs)
653+ let typer = NormalizingUnboxedClosureTyper :: new ( self . tcx ( ) ) ;
654+ typer. unboxed_closure_upvars ( def_id, substs)
656655 }
657656}
658657
@@ -948,7 +947,8 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
948947
949948 // Do the initial selection for the obligation. This yields the
950949 // shallow result we are looking for -- that is, what specific impl.
951- let mut selcx = traits:: SelectionContext :: new ( & infcx, & param_env, tcx) ;
950+ let typer = NormalizingUnboxedClosureTyper :: new ( infcx. tcx ) ;
951+ let mut selcx = traits:: SelectionContext :: new ( & infcx, & param_env, & typer) ;
952952 let obligation = traits:: Obligation :: new ( traits:: ObligationCause :: dummy ( ) ,
953953 trait_ref. to_poly_trait_predicate ( ) ) ;
954954 let selection = match selcx. select ( & obligation) {
@@ -992,6 +992,47 @@ pub fn fulfill_obligation<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
992992 vtable
993993}
994994
995+ pub struct NormalizingUnboxedClosureTyper < ' a , ' tcx : ' a > {
996+ tcx : & ' a ty:: ctxt < ' tcx >
997+ }
998+
999+ impl < ' a , ' tcx > NormalizingUnboxedClosureTyper < ' a , ' tcx > {
1000+ pub fn new ( tcx : & ' a ty:: ctxt < ' tcx > ) -> NormalizingUnboxedClosureTyper < ' a , ' tcx > {
1001+ NormalizingUnboxedClosureTyper { tcx : tcx }
1002+ }
1003+ }
1004+
1005+ impl < ' a , ' tcx > ty:: UnboxedClosureTyper < ' tcx > for NormalizingUnboxedClosureTyper < ' a , ' tcx > {
1006+ fn unboxed_closure_kind ( & self ,
1007+ def_id : ast:: DefId )
1008+ -> ty:: UnboxedClosureKind
1009+ {
1010+ self . tcx . unboxed_closure_kind ( def_id)
1011+ }
1012+
1013+ fn unboxed_closure_type ( & self ,
1014+ def_id : ast:: DefId ,
1015+ substs : & subst:: Substs < ' tcx > )
1016+ -> ty:: ClosureTy < ' tcx >
1017+ {
1018+ // the substitutions in `substs` are already monomorphized,
1019+ // but we still must normalize associated types
1020+ let closure_ty = self . tcx . unboxed_closure_type ( def_id, substs) ;
1021+ monomorphize:: normalize_associated_type ( self . tcx , & closure_ty)
1022+ }
1023+
1024+ fn unboxed_closure_upvars ( & self ,
1025+ def_id : ast:: DefId ,
1026+ substs : & Substs < ' tcx > )
1027+ -> Option < Vec < ty:: UnboxedClosureUpvar < ' tcx > > >
1028+ {
1029+ // the substitutions in `substs` are already monomorphized,
1030+ // but we still must normalize associated types
1031+ let result = ty:: unboxed_closure_upvars ( self . tcx , def_id, substs) ;
1032+ monomorphize:: normalize_associated_type ( self . tcx , & result)
1033+ }
1034+ }
1035+
9951036pub fn drain_fulfillment_cx < ' a , ' tcx , T > ( span : Span ,
9961037 infcx : & infer:: InferCtxt < ' a , ' tcx > ,
9971038 param_env : & ty:: ParameterEnvironment < ' tcx > ,
@@ -1006,7 +1047,8 @@ pub fn drain_fulfillment_cx<'a,'tcx,T>(span: Span,
10061047 // In principle, we only need to do this so long as `result`
10071048 // contains unbound type parameters. It could be a slight
10081049 // optimization to stop iterating early.
1009- match fulfill_cx. select_all_or_error ( infcx, param_env, infcx. tcx ) {
1050+ let typer = NormalizingUnboxedClosureTyper :: new ( infcx. tcx ) ;
1051+ match fulfill_cx. select_all_or_error ( infcx, param_env, & typer) {
10101052 Ok ( ( ) ) => { }
10111053 Err ( errors) => {
10121054 if errors. iter ( ) . all ( |e| e. is_overflow ( ) ) {
0 commit comments