@@ -258,10 +258,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
258
258
ex. span = e. span ;
259
259
}
260
260
// Merge attributes into the inner expression.
261
- let mut attrs: Vec < _ > = e. attrs . iter ( ) . map ( |a| self . lower_attr ( a) ) . collect ( ) ;
262
- attrs. extend :: < Vec < _ > > ( ex. attrs . into ( ) ) ;
263
- self . attrs [ ex. hir_id ] = & * self . arena . alloc_from_iter ( attrs. iter ( ) . cloned ( ) ) ;
264
- ex. attrs = attrs. into ( ) ;
261
+ self . attrs [ ex. hir_id ] = & * self . arena . alloc_from_iter (
262
+ e. attrs
263
+ . iter ( )
264
+ . map ( |a| self . lower_attr ( a) )
265
+ . chain ( self . attrs [ ex. hir_id ] . iter ( ) . cloned ( ) ) ,
266
+ ) ;
265
267
return ex;
266
268
}
267
269
@@ -274,9 +276,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
274
276
} ;
275
277
276
278
let hir_id = self . lower_node_id ( e. id ) ;
277
- let attrs = e. attrs . iter ( ) . map ( |a| self . lower_attr ( a) ) . collect :: < Vec < _ > > ( ) ;
278
- self . attrs . push_sparse ( hir_id, & * self . arena . alloc_from_iter ( attrs. iter ( ) . cloned ( ) ) ) ;
279
- hir:: Expr { hir_id, kind, span : e. span , attrs : attrs. into ( ) }
279
+ self . lower_attrs ( hir_id, & e. attrs ) ;
280
+ hir:: Expr { hir_id, kind, span : e. span }
280
281
} )
281
282
}
282
283
@@ -684,12 +685,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
684
685
span,
685
686
Some ( hir:: Movability :: Static ) ,
686
687
) ;
687
- let generator = hir:: Expr {
688
- hir_id : self . lower_node_id ( closure_node_id) ,
689
- kind : generator_kind,
690
- span,
691
- attrs : ThinVec :: new ( ) ,
692
- } ;
688
+ let generator =
689
+ hir:: Expr { hir_id : self . lower_node_id ( closure_node_id) , kind : generator_kind, span } ;
693
690
694
691
// `future::from_generator`:
695
692
let unstable_span =
@@ -843,7 +840,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
843
840
hir_id : loop_hir_id,
844
841
kind : hir:: ExprKind :: Loop ( loop_block, None , hir:: LoopSource :: Loop , span) ,
845
842
span,
846
- attrs : ThinVec :: new ( ) ,
847
843
} ) ;
848
844
849
845
// mut pinned => loop { ... }
@@ -1813,12 +1809,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
1813
1809
hir:: LoopSource :: ForLoop ,
1814
1810
e. span . with_hi ( orig_head_span. hi ( ) ) ,
1815
1811
) ;
1816
- let loop_expr = self . arena . alloc ( hir:: Expr {
1817
- hir_id : self . lower_node_id ( e. id ) ,
1818
- kind,
1819
- span : e. span ,
1820
- attrs : ThinVec :: new ( ) ,
1821
- } ) ;
1812
+ let loop_expr =
1813
+ self . arena . alloc ( hir:: Expr { hir_id : self . lower_node_id ( e. id ) , kind, span : e. span } ) ;
1822
1814
1823
1815
// `mut iter => { ... }`
1824
1816
let iter_arm = self . arm ( iter_pat, loop_expr) ;
@@ -2154,8 +2146,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
2154
2146
attrs : AttrVec ,
2155
2147
) -> hir:: Expr < ' hir > {
2156
2148
let hir_id = self . next_id ( ) ;
2157
- self . attrs . push_sparse ( hir_id, & * self . arena . alloc_from_iter ( attrs. iter ( ) . cloned ( ) ) ) ;
2158
- hir:: Expr { hir_id, kind, span, attrs }
2149
+ self . lower_attrs ( hir_id, & attrs) ;
2150
+ hir:: Expr { hir_id, kind, span }
2159
2151
}
2160
2152
2161
2153
fn field ( & mut self , ident : Ident , expr : & ' hir hir:: Expr < ' hir > , span : Span ) -> hir:: Field < ' hir > {
0 commit comments