@@ -6,7 +6,7 @@ use rustc_errors::ErrorGuaranteed;
66use rustc_hir as hir;
77use rustc_hir:: lang_items:: LangItem ;
88use rustc_hir_analysis:: hir_ty_lowering:: HirTyLowerer ;
9- use rustc_infer:: infer:: type_variable:: { TypeVariableOrigin , TypeVariableOriginKind } ;
9+ use rustc_infer:: infer:: type_variable:: TypeVariableOrigin ;
1010use rustc_infer:: infer:: { BoundRegionConversionTime , DefineOpaqueTypes } ;
1111use rustc_infer:: infer:: { InferOk , InferResult } ;
1212use rustc_macros:: { TypeFoldable , TypeVisitable } ;
@@ -72,10 +72,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7272 let parent_args =
7373 GenericArgs :: identity_for_item ( tcx, tcx. typeck_root_def_id ( expr_def_id. to_def_id ( ) ) ) ;
7474
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 } ) ;
7977
8078 // FIXME: We could probably actually just unify this further --
8179 // instead of having a `FnSig` and a `Option<CoroutineTypes>`,
@@ -102,11 +100,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
102100
103101 // Create a type variable (for now) to represent the closure kind.
104102 // 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+ }
110106 } ;
111107
112108 let closure_args = ty:: ClosureArgs :: new (
@@ -126,7 +122,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
126122 hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: Gen , _)
127123 | hir:: CoroutineKind :: Coroutine ( _) => {
128124 let yield_ty = self . next_ty_var ( TypeVariableOrigin {
129- kind : TypeVariableOriginKind :: ClosureSynthetic ,
125+ param_def_id : None ,
130126 span : expr_span,
131127 } ) ;
132128 self . require_type_is_sized ( yield_ty, expr_span, traits:: SizedYieldType ) ;
@@ -138,7 +134,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
138134 // not a problem.
139135 hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: AsyncGen , _) => {
140136 let yield_ty = self . next_ty_var ( TypeVariableOrigin {
141- kind : TypeVariableOriginKind :: ClosureSynthetic ,
137+ param_def_id : None ,
142138 span : expr_span,
143139 } ) ;
144140 self . require_type_is_sized ( yield_ty, expr_span, traits:: SizedYieldType ) ;
@@ -166,10 +162,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
166162 // Resume type defaults to `()` if the coroutine has no argument.
167163 let resume_ty = liberated_sig. inputs ( ) . get ( 0 ) . copied ( ) . unwrap_or ( tcx. types . unit ) ;
168164
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 } ) ;
173167 self . deferred_coroutine_interiors . borrow_mut ( ) . push ( (
174168 expr_def_id,
175169 body. id ( ) ,
@@ -181,11 +175,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
181175 // later during upvar analysis. Regular coroutines always have the kind
182176 // ty of `().`
183177 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+ }
189181 _ => tcx. types . unit ,
190182 } ;
191183
@@ -219,30 +211,23 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
219211 }
220212 } ;
221213 // 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 } ) ;
230218
231219 let closure_kind_ty = match expected_kind {
232220 Some ( kind) => Ty :: from_closure_kind ( tcx, kind) ,
233221
234222 // Create a type variable (for now) to represent the closure kind.
235223 // 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+ }
240227 } ;
241228
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 } ) ;
246231 let closure_args = ty:: CoroutineClosureArgs :: new (
247232 tcx,
248233 ty:: CoroutineClosureArgsParts {
@@ -274,16 +259,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
274259
275260 // Create a type variable (for now) to represent the closure kind.
276261 // 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+ }
281265 } ;
282266
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 } ) ;
287269
288270 // We need to turn the liberated signature that we got from HIR, which
289271 // looks something like `|Args...| -> T`, into a signature that is suitable
0 commit comments