@@ -6,7 +6,6 @@ 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 ;
109use rustc_infer:: infer:: { BoundRegionConversionTime , DefineOpaqueTypes } ;
1110use rustc_infer:: infer:: { InferOk , InferResult } ;
1211use rustc_macros:: { TypeFoldable , TypeVisitable } ;
@@ -73,8 +72,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
7372 let parent_args =
7473 GenericArgs :: identity_for_item ( tcx, tcx. typeck_root_def_id ( expr_def_id. to_def_id ( ) ) ) ;
7574
76- let tupled_upvars_ty =
77- self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
75+ let tupled_upvars_ty = self . next_ty_var ( expr_span) ;
7876
7977 // FIXME: We could probably actually just unify this further --
8078 // instead of having a `FnSig` and a `Option<CoroutineTypes>`,
@@ -101,9 +99,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
10199
102100 // Create a type variable (for now) to represent the closure kind.
103101 // It will be unified during the upvar inference phase (`upvar.rs`)
104- None => {
105- self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } )
106- }
102+ None => self . next_ty_var ( expr_span) ,
107103 } ;
108104
109105 let closure_args = ty:: ClosureArgs :: new (
@@ -122,10 +118,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
122118 let yield_ty = match kind {
123119 hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: Gen , _)
124120 | hir:: CoroutineKind :: Coroutine ( _) => {
125- let yield_ty = self . next_ty_var ( TypeVariableOrigin {
126- param_def_id : None ,
127- span : expr_span,
128- } ) ;
121+ let yield_ty = self . next_ty_var ( expr_span) ;
129122 self . require_type_is_sized ( yield_ty, expr_span, traits:: SizedYieldType ) ;
130123 yield_ty
131124 }
@@ -134,10 +127,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
134127 // in this block in projection correctly. In the new trait solver, it is
135128 // not a problem.
136129 hir:: CoroutineKind :: Desugared ( hir:: CoroutineDesugaring :: AsyncGen , _) => {
137- let yield_ty = self . next_ty_var ( TypeVariableOrigin {
138- param_def_id : None ,
139- span : expr_span,
140- } ) ;
130+ let yield_ty = self . next_ty_var ( expr_span) ;
141131 self . require_type_is_sized ( yield_ty, expr_span, traits:: SizedYieldType ) ;
142132
143133 Ty :: new_adt (
@@ -163,8 +153,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
163153 // Resume type defaults to `()` if the coroutine has no argument.
164154 let resume_ty = liberated_sig. inputs ( ) . get ( 0 ) . copied ( ) . unwrap_or ( tcx. types . unit ) ;
165155
166- let interior =
167- self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
156+ let interior = self . next_ty_var ( expr_span) ;
168157 self . deferred_coroutine_interiors . borrow_mut ( ) . push ( (
169158 expr_def_id,
170159 body. id ( ) ,
@@ -177,7 +166,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
177166 // ty of `().`
178167 let kind_ty = match kind {
179168 hir:: CoroutineKind :: Desugared ( _, hir:: CoroutineSource :: Closure ) => {
180- self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } )
169+ self . next_ty_var ( expr_span)
181170 }
182171 _ => tcx. types . unit ,
183172 } ;
@@ -212,23 +201,18 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
212201 }
213202 } ;
214203 // Compute all of the variables that will be used to populate the coroutine.
215- let resume_ty =
216- self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
217- let interior =
218- self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
204+ let resume_ty = self . next_ty_var ( expr_span) ;
205+ let interior = self . next_ty_var ( expr_span) ;
219206
220207 let closure_kind_ty = match expected_kind {
221208 Some ( kind) => Ty :: from_closure_kind ( tcx, kind) ,
222209
223210 // Create a type variable (for now) to represent the closure kind.
224211 // It will be unified during the upvar inference phase (`upvar.rs`)
225- None => {
226- self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } )
227- }
212+ None => self . next_ty_var ( expr_span) ,
228213 } ;
229214
230- let coroutine_captures_by_ref_ty =
231- self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
215+ let coroutine_captures_by_ref_ty = self . next_ty_var ( expr_span) ;
232216 let closure_args = ty:: CoroutineClosureArgs :: new (
233217 tcx,
234218 ty:: CoroutineClosureArgsParts {
@@ -260,13 +244,10 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
260244
261245 // Create a type variable (for now) to represent the closure kind.
262246 // It will be unified during the upvar inference phase (`upvar.rs`)
263- None => {
264- self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } )
265- }
247+ None => self . next_ty_var ( expr_span) ,
266248 } ;
267249
268- let coroutine_upvars_ty =
269- self . next_ty_var ( TypeVariableOrigin { param_def_id : None , span : expr_span } ) ;
250+ let coroutine_upvars_ty = self . next_ty_var ( expr_span) ;
270251
271252 // We need to turn the liberated signature that we got from HIR, which
272253 // looks something like `|Args...| -> T`, into a signature that is suitable
0 commit comments