@@ -49,7 +49,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
4949 expr_span : Span ,
5050 expected : Expectation < ' tcx > ,
5151 ) -> Ty < ' tcx > {
52- trace ! ( "decl = {:#?}" , closure. fn_decl) ;
52+ let tcx = self . tcx ;
53+ let body = tcx. hir ( ) . body ( closure. body ) ;
54+ let expr_def_id = closure. def_id ;
5355
5456 // It's always helpful for inference if we know the kind of
5557 // closure sooner rather than later, so first examine the expected
@@ -61,24 +63,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
6163 None => ( None , None ) ,
6264 } ;
6365
64- self . check_closure ( closure, expr_span, expected_kind, expected_sig)
65- }
66-
67- #[ instrument( skip( self , closure) , level = "debug" , ret) ]
68- fn check_closure (
69- & self ,
70- closure : & hir:: Closure < ' tcx > ,
71- expr_span : Span ,
72- opt_kind : Option < ty:: ClosureKind > ,
73- expected_sig : Option < ExpectedSig < ' tcx > > ,
74- ) -> Ty < ' tcx > {
75- let tcx = self . tcx ;
76- let body = tcx. hir ( ) . body ( closure. body ) ;
77-
78- trace ! ( "decl = {:#?}" , closure. fn_decl) ;
79- let expr_def_id = closure. def_id ;
80- debug ! ( ?expr_def_id) ;
81-
8266 let ClosureSignatures { bound_sig, liberated_sig } =
8367 self . sig_of_closure ( expr_def_id, closure. fn_decl , closure. kind , expected_sig) ;
8468
@@ -139,9 +123,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
139123 }
140124 } ;
141125
142- let mut fcx = FnCtxt :: new ( self , self . param_env , closure. def_id ) ;
143126 check_fn (
144- & mut fcx ,
127+ & mut FnCtxt :: new ( self , self . param_env , closure . def_id ) ,
145128 liberated_sig,
146129 coroutine_types,
147130 closure. fn_decl ,
@@ -174,9 +157,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
174157 )
175158 } ) ;
176159
177- debug ! ( ?sig, ?opt_kind ) ;
160+ debug ! ( ?sig, ?expected_kind ) ;
178161
179- let closure_kind_ty = match opt_kind {
162+ let closure_kind_ty = match expected_kind {
180163 Some ( kind) => Ty :: from_closure_kind ( tcx, kind) ,
181164
182165 // Create a type variable (for now) to represent the closure kind.
@@ -204,11 +187,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
204187 let Some ( CoroutineTypes { resume_ty, yield_ty } ) = coroutine_types else {
205188 bug ! ( "expected coroutine to have yield/resume types" ) ;
206189 } ;
207- let interior = fcx . next_ty_var ( TypeVariableOrigin {
190+ let interior = self . next_ty_var ( TypeVariableOrigin {
208191 kind : TypeVariableOriginKind :: MiscVariable ,
209192 span : body. value . span ,
210193 } ) ;
211- fcx . deferred_coroutine_interiors . borrow_mut ( ) . push ( (
194+ self . deferred_coroutine_interiors . borrow_mut ( ) . push ( (
212195 expr_def_id,
213196 body. id ( ) ,
214197 interior,
0 commit comments