@@ -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>`,
@@ -104,7 +102,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
104102 // It will be unified during the upvar inference phase (`upvar.rs`)
105103 None => self . next_ty_var ( TypeVariableOrigin {
106104 // FIXME(eddyb) distinguish closure kind inference variables from the rest.
107- kind : TypeVariableOriginKind :: ClosureSynthetic ,
105+ param_def_id : None ,
108106 span : expr_span,
109107 } ) ,
110108 } ;
@@ -126,7 +124,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
126124 hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: Gen , _)
127125 | hir:: CoroutineKind :: Coroutine ( _) => {
128126 let yield_ty = self . next_ty_var ( TypeVariableOrigin {
129- kind : TypeVariableOriginKind :: ClosureSynthetic ,
127+ param_def_id : None ,
130128 span : expr_span,
131129 } ) ;
132130 self . require_type_is_sized ( yield_ty, expr_span, traits:: SizedYieldType ) ;
@@ -138,7 +136,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
138136 // not a problem.
139137 hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: AsyncGen , _) => {
140138 let yield_ty = self . next_ty_var ( TypeVariableOrigin {
141- kind : TypeVariableOriginKind :: ClosureSynthetic ,
139+ param_def_id : None ,
142140 span : expr_span,
143141 } ) ;
144142 self . require_type_is_sized ( yield_ty, expr_span, traits:: SizedYieldType ) ;
@@ -166,10 +164,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
166164 // Resume type defaults to `()` if the coroutine has no argument.
167165 let resume_ty = liberated_sig. inputs ( ) . get ( 0 ) . copied ( ) . unwrap_or ( tcx. types . unit ) ;
168166
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 } ) ;
173169 self . deferred_coroutine_interiors . borrow_mut ( ) . push ( (
174170 expr_def_id,
175171 body. id ( ) ,
@@ -181,11 +177,9 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
181177 // later during upvar analysis. Regular coroutines always have the kind
182178 // ty of `().`
183179 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+ }
189183 _ => tcx. types . unit ,
190184 } ;
191185
@@ -219,23 +213,17 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
219213 }
220214 } ;
221215 // 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 } ) ;
230220 let closure_kind_ty = self . next_ty_var ( TypeVariableOrigin {
231221 // 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 ,
237223 span : expr_span,
238224 } ) ;
225+ let coroutine_captures_by_ref_ty =
226+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
239227 let closure_args = ty:: CoroutineClosureArgs :: new (
240228 tcx,
241229 ty:: CoroutineClosureArgsParts {
@@ -262,14 +250,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
262250 } ,
263251 ) ;
264252
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 } ) ;
273257
274258 // We need to turn the liberated signature that we got from HIR, which
275259 // looks something like `|Args...| -> T`, into a signature that is suitable
0 commit comments