@@ -49,7 +49,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
49
49
expr_span : Span ,
50
50
expected : Expectation < ' tcx > ,
51
51
) -> 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 ;
53
55
54
56
// It's always helpful for inference if we know the kind of
55
57
// closure sooner rather than later, so first examine the expected
@@ -61,24 +63,6 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
61
63
None => ( None , None ) ,
62
64
} ;
63
65
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
-
82
66
let ClosureSignatures { bound_sig, liberated_sig } =
83
67
self . sig_of_closure ( expr_def_id, closure. fn_decl , closure. kind , expected_sig) ;
84
68
@@ -139,9 +123,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
139
123
}
140
124
} ;
141
125
142
- let mut fcx = FnCtxt :: new ( self , self . param_env , closure. def_id ) ;
143
126
check_fn (
144
- & mut fcx ,
127
+ & mut FnCtxt :: new ( self , self . param_env , closure . def_id ) ,
145
128
liberated_sig,
146
129
coroutine_types,
147
130
closure. fn_decl ,
@@ -174,9 +157,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
174
157
)
175
158
} ) ;
176
159
177
- debug ! ( ?sig, ?opt_kind ) ;
160
+ debug ! ( ?sig, ?expected_kind ) ;
178
161
179
- let closure_kind_ty = match opt_kind {
162
+ let closure_kind_ty = match expected_kind {
180
163
Some ( kind) => Ty :: from_closure_kind ( tcx, kind) ,
181
164
182
165
// Create a type variable (for now) to represent the closure kind.
@@ -204,11 +187,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
204
187
let Some ( CoroutineTypes { resume_ty, yield_ty } ) = coroutine_types else {
205
188
bug ! ( "expected coroutine to have yield/resume types" ) ;
206
189
} ;
207
- let interior = fcx . next_ty_var ( TypeVariableOrigin {
190
+ let interior = self . next_ty_var ( TypeVariableOrigin {
208
191
kind : TypeVariableOriginKind :: MiscVariable ,
209
192
span : body. value . span ,
210
193
} ) ;
211
- fcx . deferred_coroutine_interiors . borrow_mut ( ) . push ( (
194
+ self . deferred_coroutine_interiors . borrow_mut ( ) . push ( (
212
195
expr_def_id,
213
196
body. id ( ) ,
214
197
interior,
0 commit comments