@@ -47,7 +47,7 @@ use rustc_errors::ErrorGuaranteed;
4747use rustc_hir:: def_id:: DefId ;
4848use rustc_middle:: span_bug;
4949use rustc_middle:: ty:: { Asyncness , ResolverAstLowering } ;
50- use rustc_span:: { Ident , Span } ;
50+ use rustc_span:: { Ident , Span , Symbol } ;
5151use { rustc_ast as ast, rustc_hir as hir} ;
5252
5353use super :: { GenericArgsMode , ImplTraitContext , LoweringContext , ParamMode } ;
@@ -234,22 +234,23 @@ impl<'hir> LoweringContext<'_, 'hir> {
234234 hir:: FnSig { decl, header, span }
235235 }
236236
237- fn generate_param ( & mut self , span : Span ) -> ( hir:: Param < ' hir > , NodeId ) {
237+ fn generate_param ( & mut self , idx : usize , span : Span ) -> ( hir:: Param < ' hir > , NodeId ) {
238238 let pat_node_id = self . next_node_id ( ) ;
239239 let pat_id = self . lower_node_id ( pat_node_id) ;
240+ let ident = Ident :: with_dummy_span ( Symbol :: intern ( & format ! ( "arg{idx}" ) ) ) ;
240241 let pat = self . arena . alloc ( hir:: Pat {
241242 hir_id : pat_id,
242- kind : hir:: PatKind :: Binding ( hir:: BindingMode :: NONE , pat_id, Ident :: empty ( ) , None ) ,
243+ kind : hir:: PatKind :: Binding ( hir:: BindingMode :: NONE , pat_id, ident , None ) ,
243244 span,
244245 default_binding_modes : false ,
245246 } ) ;
246247
247248 ( hir:: Param { hir_id : self . next_id ( ) , pat, ty_span : span, span } , pat_node_id)
248249 }
249250
250- fn generate_arg ( & mut self , param_id : HirId , span : Span ) -> hir:: Expr < ' hir > {
251+ fn generate_arg ( & mut self , idx : usize , param_id : HirId , span : Span ) -> hir:: Expr < ' hir > {
251252 let segments = self . arena . alloc_from_iter ( iter:: once ( hir:: PathSegment {
252- ident : Ident :: empty ( ) ,
253+ ident : Ident :: with_dummy_span ( Symbol :: intern ( & format ! ( "arg{idx}" ) ) ) ,
253254 hir_id : self . next_id ( ) ,
254255 res : Res :: Local ( param_id) ,
255256 args : None ,
@@ -273,7 +274,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
273274 let mut args: Vec < hir:: Expr < ' _ > > = Vec :: with_capacity ( param_count) ;
274275
275276 for idx in 0 ..param_count {
276- let ( param, pat_node_id) = this. generate_param ( span) ;
277+ let ( param, pat_node_id) = this. generate_param ( idx , span) ;
277278 parameters. push ( param) ;
278279
279280 let arg = if let Some ( block) = block
@@ -289,7 +290,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
289290 this. ident_and_label_to_local_id . insert ( pat_node_id, param. pat . hir_id . local_id ) ;
290291 this. lower_target_expr ( & block)
291292 } else {
292- this. generate_arg ( param. pat . hir_id , span)
293+ this. generate_arg ( idx , param. pat . hir_id , span)
293294 } ;
294295 args. push ( arg) ;
295296 }
0 commit comments