@@ -2433,7 +2433,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2433
2433
}
2434
2434
2435
2435
fn lower_stmt ( & mut self , s : & Stmt ) -> SmallVec < [ hir:: Stmt < ' hir > ; 1 ] > {
2436
- let kind = match s. kind {
2436
+ let ( hir_id , kind) = match s. kind {
2437
2437
StmtKind :: Local ( ref l) => {
2438
2438
let ( l, item_ids) = self . lower_local ( l) ;
2439
2439
let mut ids: SmallVec < [ hir:: Stmt < ' hir > ; 1 ] > = item_ids
@@ -2446,9 +2446,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2446
2446
self . stmt ( s. span , hir:: StmtKind :: Item ( item_id) )
2447
2447
} )
2448
2448
. collect ( ) ;
2449
+ let hir_id = self . lower_node_id ( s. id ) ;
2450
+ self . attrs . push_sparse ( hir_id, self . attrs [ l. hir_id ] ) ;
2449
2451
ids. push ( {
2450
2452
hir:: Stmt {
2451
- hir_id : self . lower_node_id ( s . id ) ,
2453
+ hir_id,
2452
2454
kind : hir:: StmtKind :: Local ( self . arena . alloc ( l) ) ,
2453
2455
span : s. span ,
2454
2456
}
@@ -2471,12 +2473,22 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
2471
2473
} )
2472
2474
. collect ( ) ;
2473
2475
}
2474
- StmtKind :: Expr ( ref e) => hir:: StmtKind :: Expr ( self . lower_expr ( e) ) ,
2475
- StmtKind :: Semi ( ref e) => hir:: StmtKind :: Semi ( self . lower_expr ( e) ) ,
2476
+ StmtKind :: Expr ( ref e) => {
2477
+ let e = self . lower_expr ( e) ;
2478
+ let hir_id = self . lower_node_id ( s. id ) ;
2479
+ self . attrs . push_sparse ( hir_id, self . attrs [ e. hir_id ] ) ;
2480
+ ( hir_id, hir:: StmtKind :: Expr ( e) )
2481
+ }
2482
+ StmtKind :: Semi ( ref e) => {
2483
+ let e = self . lower_expr ( e) ;
2484
+ let hir_id = self . lower_node_id ( s. id ) ;
2485
+ self . attrs . push_sparse ( hir_id, self . attrs [ e. hir_id ] ) ;
2486
+ ( hir_id, hir:: StmtKind :: Semi ( e) )
2487
+ }
2476
2488
StmtKind :: Empty => return smallvec ! [ ] ,
2477
2489
StmtKind :: MacCall ( ..) => panic ! ( "shouldn't exist here" ) ,
2478
2490
} ;
2479
- smallvec ! [ hir:: Stmt { hir_id: self . lower_node_id ( s . id ) , kind, span: s. span } ]
2491
+ smallvec ! [ hir:: Stmt { hir_id, kind, span: s. span } ]
2480
2492
}
2481
2493
2482
2494
fn lower_block_check_mode ( & mut self , b : & BlockCheckMode ) -> hir:: BlockCheckMode {
0 commit comments