@@ -6,7 +6,7 @@ use rustc_errors::ErrorGuaranteed;
6
6
use rustc_hir as hir;
7
7
use rustc_hir:: lang_items:: LangItem ;
8
8
use rustc_hir_analysis:: hir_ty_lowering:: HirTyLowerer ;
9
- use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
9
+ use rustc_infer:: infer:: type_variable:: TypeVariableOrigin ;
10
10
use rustc_infer:: infer:: { BoundRegionConversionTime , DefineOpaqueTypes } ;
11
11
use rustc_infer:: infer:: { InferOk , InferResult } ;
12
12
use rustc_macros:: { TypeFoldable , TypeVisitable } ;
@@ -72,10 +72,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
72
72
let parent_args =
73
73
GenericArgs :: identity_for_item ( tcx, tcx. typeck_root_def_id ( expr_def_id. to_def_id ( ) ) ) ;
74
74
75
- let tupled_upvars_ty = self . next_ty_var ( TypeVariableOrigin {
76
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
77
- span : expr_span,
78
- } ) ;
75
+ let tupled_upvars_ty =
76
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
79
77
80
78
// FIXME: We could probably actually just unify this further --
81
79
// instead of having a `FnSig` and a `Option<CoroutineTypes>`,
@@ -102,11 +100,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
102
100
103
101
// Create a type variable (for now) to represent the closure kind.
104
102
// It will be unified during the upvar inference phase (`upvar.rs`)
105
- None => self . next_ty_var ( TypeVariableOrigin {
106
- // FIXME(eddyb) distinguish closure kind inference variables from the rest.
107
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
108
- span : expr_span,
109
- } ) ,
103
+ None => {
104
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } )
105
+ }
110
106
} ;
111
107
112
108
let closure_args = ty:: ClosureArgs :: new (
@@ -126,7 +122,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
126
122
hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: Gen , _)
127
123
| hir:: CoroutineKind :: Coroutine ( _) => {
128
124
let yield_ty = self . next_ty_var ( TypeVariableOrigin {
129
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
125
+ param_def_id : None ,
130
126
span : expr_span,
131
127
} ) ;
132
128
self . require_type_is_sized ( yield_ty, expr_span, traits:: SizedYieldType ) ;
@@ -138,7 +134,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
138
134
// not a problem.
139
135
hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: AsyncGen , _) => {
140
136
let yield_ty = self . next_ty_var ( TypeVariableOrigin {
141
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
137
+ param_def_id : None ,
142
138
span : expr_span,
143
139
} ) ;
144
140
self . require_type_is_sized ( yield_ty, expr_span, traits:: SizedYieldType ) ;
@@ -166,10 +162,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
166
162
// Resume type defaults to `()` if the coroutine has no argument.
167
163
let resume_ty = liberated_sig. inputs ( ) . get ( 0 ) . copied ( ) . unwrap_or ( tcx. types . unit ) ;
168
164
169
- let interior = self . next_ty_var ( TypeVariableOrigin {
170
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
171
- span : expr_span,
172
- } ) ;
165
+ let interior =
166
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
173
167
self . deferred_coroutine_interiors . borrow_mut ( ) . push ( (
174
168
expr_def_id,
175
169
body. id ( ) ,
@@ -181,11 +175,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
181
175
// later during upvar analysis. Regular coroutines always have the kind
182
176
// ty of `().`
183
177
let kind_ty = match kind {
184
- hir:: CoroutineKind :: Desugared ( _, hir:: CoroutineSource :: Closure ) => self
185
- . next_ty_var ( TypeVariableOrigin {
186
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
187
- span : expr_span,
188
- } ) ,
178
+ hir:: CoroutineKind :: Desugared ( _, hir:: CoroutineSource :: Closure ) => {
179
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } )
180
+ }
189
181
_ => tcx. types . unit ,
190
182
} ;
191
183
@@ -219,30 +211,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
219
211
}
220
212
} ;
221
213
// Compute all of the variables that will be used to populate the coroutine.
222
- let resume_ty = self . next_ty_var ( TypeVariableOrigin {
223
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
224
- span : expr_span,
225
- } ) ;
226
- let interior = self . next_ty_var ( TypeVariableOrigin {
227
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
228
- span : expr_span,
229
- } ) ;
214
+ let resume_ty =
215
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
216
+ let interior =
217
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
230
218
231
219
let closure_kind_ty = match expected_kind {
232
220
Some ( kind) => Ty :: from_closure_kind ( tcx, kind) ,
233
221
234
222
// Create a type variable (for now) to represent the closure kind.
235
223
// It will be unified during the upvar inference phase (`upvar.rs`)
236
- None => self . next_ty_var ( TypeVariableOrigin {
237
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
238
- span : expr_span,
239
- } ) ,
224
+ None => {
225
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } )
226
+ }
240
227
} ;
241
228
242
- let coroutine_captures_by_ref_ty = self . next_ty_var ( TypeVariableOrigin {
243
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
244
- span : expr_span,
245
- } ) ;
229
+ let coroutine_captures_by_ref_ty =
230
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
246
231
let closure_args = ty:: CoroutineClosureArgs :: new (
247
232
tcx,
248
233
ty:: CoroutineClosureArgsParts {
@@ -274,16 +259,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
274
259
275
260
// Create a type variable (for now) to represent the closure kind.
276
261
// It will be unified during the upvar inference phase (`upvar.rs`)
277
- None => self . next_ty_var ( TypeVariableOrigin {
278
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
279
- span : expr_span,
280
- } ) ,
262
+ None => {
263
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } )
264
+ }
281
265
} ;
282
266
283
- let coroutine_upvars_ty = self . next_ty_var ( TypeVariableOrigin {
284
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
285
- span : expr_span,
286
- } ) ;
267
+ let coroutine_upvars_ty =
268
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
287
269
288
270
// We need to turn the liberated signature that we got from HIR, which
289
271
// looks something like `|Args...| -> T`, into a signature that is suitable
0 commit comments