@@ -2461,8 +2461,10 @@ impl<'a> LoweringContext<'a> {
2461
2461
2462
2462
fn lower_arg ( & mut self , arg : & Arg ) -> hir:: Arg {
2463
2463
hir:: Arg {
2464
+ attrs : self . lower_attrs ( & arg. attrs ) ,
2464
2465
hir_id : self . lower_node_id ( arg. id ) ,
2465
2466
pat : self . lower_pat ( & arg. pat ) ,
2467
+ span : arg. span ,
2466
2468
}
2467
2469
}
2468
2470
@@ -3279,19 +3281,29 @@ impl<'a> LoweringContext<'a> {
3279
3281
//
3280
3282
// If this is the simple case, this argument will end up being the same as the
3281
3283
// original argument, but with a different pattern id.
3284
+ let mut stmt_attrs = ThinVec :: new ( ) ;
3285
+ stmt_attrs. extend ( argument. attrs . iter ( ) . cloned ( ) ) ;
3282
3286
let ( new_argument_pat, new_argument_id) = this. pat_ident ( desugared_span, ident) ;
3283
3287
let new_argument = hir:: Arg {
3288
+ attrs : argument. attrs ,
3284
3289
hir_id : argument. hir_id ,
3285
3290
pat : new_argument_pat,
3291
+ span : argument. span ,
3286
3292
} ;
3287
3293
3294
+
3288
3295
if is_simple_argument {
3289
3296
// If this is the simple case, then we only insert one statement that is
3290
3297
// `let <pat> = <pat>;`. We re-use the original argument's pattern so that
3291
3298
// `HirId`s are densely assigned.
3292
3299
let expr = this. expr_ident ( desugared_span, ident, new_argument_id) ;
3293
3300
let stmt = this. stmt_let_pat (
3294
- desugared_span, Some ( P ( expr) ) , argument. pat , hir:: LocalSource :: AsyncFn ) ;
3301
+ stmt_attrs,
3302
+ desugared_span,
3303
+ Some ( P ( expr) ) ,
3304
+ argument. pat ,
3305
+ hir:: LocalSource :: AsyncFn
3306
+ ) ;
3295
3307
statements. push ( stmt) ;
3296
3308
} else {
3297
3309
// If this is not the simple case, then we construct two statements:
@@ -3313,14 +3325,23 @@ impl<'a> LoweringContext<'a> {
3313
3325
desugared_span, ident, hir:: BindingAnnotation :: Mutable ) ;
3314
3326
let move_expr = this. expr_ident ( desugared_span, ident, new_argument_id) ;
3315
3327
let move_stmt = this. stmt_let_pat (
3316
- desugared_span, Some ( P ( move_expr) ) , move_pat, hir:: LocalSource :: AsyncFn ) ;
3328
+ ThinVec :: new ( ) ,
3329
+ desugared_span,
3330
+ Some ( P ( move_expr) ) ,
3331
+ move_pat,
3332
+ hir:: LocalSource :: AsyncFn
3333
+ ) ;
3317
3334
3318
3335
// Construct the `let <pat> = __argN;` statement. We re-use the original
3319
3336
// argument's pattern so that `HirId`s are densely assigned.
3320
3337
let pattern_expr = this. expr_ident ( desugared_span, ident, move_id) ;
3321
3338
let pattern_stmt = this. stmt_let_pat (
3322
- desugared_span, Some ( P ( pattern_expr) ) , argument. pat ,
3323
- hir:: LocalSource :: AsyncFn ) ;
3339
+ stmt_attrs,
3340
+ desugared_span,
3341
+ Some ( P ( pattern_expr) ) ,
3342
+ argument. pat ,
3343
+ hir:: LocalSource :: AsyncFn
3344
+ ) ;
3324
3345
3325
3346
statements. push ( move_stmt) ;
3326
3347
statements. push ( pattern_stmt) ;
@@ -5030,6 +5051,7 @@ impl<'a> LoweringContext<'a> {
5030
5051
5031
5052
// `let mut __next`
5032
5053
let next_let = self . stmt_let_pat (
5054
+ ThinVec :: new ( ) ,
5033
5055
desugared_span,
5034
5056
None ,
5035
5057
next_pat,
@@ -5039,6 +5061,7 @@ impl<'a> LoweringContext<'a> {
5039
5061
// `let <pat> = __next`
5040
5062
let pat = self . lower_pat ( pat) ;
5041
5063
let pat_let = self . stmt_let_pat (
5064
+ ThinVec :: new ( ) ,
5042
5065
head_sp,
5043
5066
Some ( next_expr) ,
5044
5067
pat,
@@ -5533,19 +5556,20 @@ impl<'a> LoweringContext<'a> {
5533
5556
5534
5557
fn stmt_let_pat (
5535
5558
& mut self ,
5559
+ attrs : ThinVec < Attribute > ,
5536
5560
span : Span ,
5537
5561
init : Option < P < hir:: Expr > > ,
5538
5562
pat : P < hir:: Pat > ,
5539
5563
source : hir:: LocalSource ,
5540
5564
) -> hir:: Stmt {
5541
5565
let local = hir:: Local {
5542
- pat,
5543
- ty : None ,
5544
- init,
5566
+ attrs,
5545
5567
hir_id : self . next_id ( ) ,
5546
- span,
5568
+ init,
5569
+ pat,
5547
5570
source,
5548
- attrs : ThinVec :: new ( )
5571
+ span,
5572
+ ty : None ,
5549
5573
} ;
5550
5574
self . stmt ( span, hir:: StmtKind :: Local ( P ( local) ) )
5551
5575
}
@@ -5959,6 +5983,7 @@ impl<'a> LoweringContext<'a> {
5959
5983
hir:: BindingAnnotation :: Mutable ,
5960
5984
) ;
5961
5985
let pinned_let = self . stmt_let_pat (
5986
+ ThinVec :: new ( ) ,
5962
5987
span,
5963
5988
Some ( expr) ,
5964
5989
pinned_pat,
0 commit comments