@@ -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>`,
@@ -104,7 +102,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
104
102
// It will be unified during the upvar inference phase (`upvar.rs`)
105
103
None => self . next_ty_var ( TypeVariableOrigin {
106
104
// FIXME(eddyb) distinguish closure kind inference variables from the rest.
107
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
105
+ param_def_id : None ,
108
106
span : expr_span,
109
107
} ) ,
110
108
} ;
@@ -126,7 +124,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
126
124
hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: Gen , _)
127
125
| hir:: CoroutineKind :: Coroutine ( _) => {
128
126
let yield_ty = self . next_ty_var ( TypeVariableOrigin {
129
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
127
+ param_def_id : None ,
130
128
span : expr_span,
131
129
} ) ;
132
130
self . require_type_is_sized ( yield_ty, expr_span, traits:: SizedYieldType ) ;
@@ -138,7 +136,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
138
136
// not a problem.
139
137
hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: AsyncGen , _) => {
140
138
let yield_ty = self . next_ty_var ( TypeVariableOrigin {
141
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
139
+ param_def_id : None ,
142
140
span : expr_span,
143
141
} ) ;
144
142
self . require_type_is_sized ( yield_ty, expr_span, traits:: SizedYieldType ) ;
@@ -166,10 +164,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
166
164
// Resume type defaults to `()` if the coroutine has no argument.
167
165
let resume_ty = liberated_sig. inputs ( ) . get ( 0 ) . copied ( ) . unwrap_or ( tcx. types . unit ) ;
168
166
169
- let interior = self . next_ty_var ( TypeVariableOrigin {
170
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
171
- span : expr_span,
172
- } ) ;
167
+ let interior =
168
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
173
169
self . deferred_coroutine_interiors . borrow_mut ( ) . push ( (
174
170
expr_def_id,
175
171
body. id ( ) ,
@@ -181,11 +177,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
181
177
// later during upvar analysis. Regular coroutines always have the kind
182
178
// ty of `().`
183
179
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
- } ) ,
180
+ hir:: CoroutineKind :: Desugared ( _, hir:: CoroutineSource :: Closure ) => {
181
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } )
182
+ }
189
183
_ => tcx. types . unit ,
190
184
} ;
191
185
@@ -219,23 +213,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
219
213
}
220
214
} ;
221
215
// 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
- } ) ;
216
+ let resume_ty =
217
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
218
+ let interior =
219
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
230
220
let closure_kind_ty = self . next_ty_var ( TypeVariableOrigin {
231
221
// FIXME(eddyb) distinguish closure kind inference variables from the rest.
232
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
233
- span : expr_span,
234
- } ) ;
235
- let coroutine_captures_by_ref_ty = self . next_ty_var ( TypeVariableOrigin {
236
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
222
+ param_def_id : None ,
237
223
span : expr_span,
238
224
} ) ;
225
+ let coroutine_captures_by_ref_ty =
226
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
239
227
let closure_args = ty:: CoroutineClosureArgs :: new (
240
228
tcx,
241
229
ty:: CoroutineClosureArgsParts {
@@ -262,14 +250,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
262
250
} ,
263
251
) ;
264
252
265
- let coroutine_kind_ty = self . next_ty_var ( TypeVariableOrigin {
266
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
267
- span : expr_span,
268
- } ) ;
269
- let coroutine_upvars_ty = self . next_ty_var ( TypeVariableOrigin {
270
- kind : TypeVariableOriginKind :: ClosureSynthetic ,
271
- span : expr_span,
272
- } ) ;
253
+ let coroutine_kind_ty =
254
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
255
+ let coroutine_upvars_ty =
256
+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
273
257
274
258
// We need to turn the liberated signature that we got from HIR, which
275
259
// looks something like `|Args...| -> T`, into a signature that is suitable
0 commit comments