@@ -2433,7 +2433,7 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24332433 }
24342434
24352435 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 {
24372437 StmtKind :: Local ( ref l) => {
24382438 let ( l, item_ids) = self . lower_local ( l) ;
24392439 let mut ids: SmallVec < [ hir:: Stmt < ' hir > ; 1 ] > = item_ids
@@ -2446,9 +2446,11 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24462446 self . stmt ( s. span , hir:: StmtKind :: Item ( item_id) )
24472447 } )
24482448 . collect ( ) ;
2449+ let hir_id = self . lower_node_id ( s. id ) ;
2450+ self . attrs . push_sparse ( hir_id, self . attrs [ l. hir_id ] ) ;
24492451 ids. push ( {
24502452 hir:: Stmt {
2451- hir_id : self . lower_node_id ( s . id ) ,
2453+ hir_id,
24522454 kind : hir:: StmtKind :: Local ( self . arena . alloc ( l) ) ,
24532455 span : s. span ,
24542456 }
@@ -2471,12 +2473,22 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
24712473 } )
24722474 . collect ( ) ;
24732475 }
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+ }
24762488 StmtKind :: Empty => return smallvec ! [ ] ,
24772489 StmtKind :: MacCall ( ..) => panic ! ( "shouldn't exist here" ) ,
24782490 } ;
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 } ]
24802492 }
24812493
24822494 fn lower_block_check_mode ( & mut self , b : & BlockCheckMode ) -> hir:: BlockCheckMode {
0 commit comments