@@ -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,30 +213,23 @@ 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
231221 let closure_kind_ty = match expected_kind {
232222 Some ( kind) => Ty :: from_closure_kind ( tcx, kind) ,
233223
234224 // Create a type variable (for now) to represent the closure kind.
235225 // 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- } ) ,
226+ None => {
227+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } )
228+ }
240229 } ;
241230
242- let coroutine_captures_by_ref_ty = self . next_ty_var ( TypeVariableOrigin {
243- kind : TypeVariableOriginKind :: ClosureSynthetic ,
244- span : expr_span,
245- } ) ;
231+ let coroutine_captures_by_ref_ty =
232+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
246233 let closure_args = ty:: CoroutineClosureArgs :: new (
247234 tcx,
248235 ty:: CoroutineClosureArgsParts {
@@ -274,16 +261,13 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
274261
275262 // Create a type variable (for now) to represent the closure kind.
276263 // 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- } ) ,
264+ None => {
265+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } )
266+ }
281267 } ;
282268
283- let coroutine_upvars_ty = self . next_ty_var ( TypeVariableOrigin {
284- kind : TypeVariableOriginKind :: ClosureSynthetic ,
285- span : expr_span,
286- } ) ;
269+ let coroutine_upvars_ty =
270+ self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
287271
288272 // We need to turn the liberated signature that we got from HIR, which
289273 // looks something like `|Args...| -> T`, into a signature that is suitable
0 commit comments