@@ -436,18 +436,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
436436 let lhs = self . lower_cond ( lhs) ;
437437 let rhs = self . lower_cond ( rhs) ;
438438
439- self . arena . alloc ( self . expr (
440- cond. span ,
441- hir:: ExprKind :: Binary ( op, lhs, rhs) ,
442- AttrVec :: new ( ) ,
443- ) )
439+ self . arena . alloc ( self . expr ( cond. span , hir:: ExprKind :: Binary ( op, lhs, rhs) ) )
444440 }
445441 ExprKind :: Let ( ..) => self . lower_expr ( cond) ,
446442 _ => {
447443 let cond = self . lower_expr ( cond) ;
448444 let reason = DesugaringKind :: CondTemporary ;
449445 let span_block = self . mark_span_with_reason ( reason, cond. span , None ) ;
450- self . expr_drop_temps ( span_block, cond, AttrVec :: new ( ) )
446+ self . expr_drop_temps ( span_block, cond)
451447 }
452448 }
453449 }
@@ -477,12 +473,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
477473 ) -> hir:: ExprKind < ' hir > {
478474 let lowered_cond = self . with_loop_condition_scope ( |t| t. lower_cond ( cond) ) ;
479475 let then = self . lower_block_expr ( body) ;
480- let expr_break = self . expr_break ( span, AttrVec :: new ( ) ) ;
476+ let expr_break = self . expr_break ( span) ;
481477 let stmt_break = self . stmt_expr ( span, expr_break) ;
482478 let else_blk = self . block_all ( span, arena_vec ! [ self ; stmt_break] , None ) ;
483- let else_expr = self . arena . alloc ( self . expr_block ( else_blk, AttrVec :: new ( ) ) ) ;
479+ let else_expr = self . arena . alloc ( self . expr_block ( else_blk) ) ;
484480 let if_kind = hir:: ExprKind :: If ( lowered_cond, self . arena . alloc ( then) , Some ( else_expr) ) ;
485- let if_expr = self . expr ( span, if_kind, AttrVec :: new ( ) ) ;
481+ let if_expr = self . expr ( span, if_kind) ;
486482 let block = self . block_expr ( self . arena . alloc ( if_expr) ) ;
487483 let span = self . lower_span ( span. with_hi ( cond. span . hi ( ) ) ) ;
488484 let opt_label = self . lower_label ( opt_label) ;
@@ -538,12 +534,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
538534 expr : & ' hir hir:: Expr < ' hir > ,
539535 overall_span : Span ,
540536 ) -> & ' hir hir:: Expr < ' hir > {
541- let constructor = self . arena . alloc ( self . expr_lang_item_path (
542- method_span,
543- lang_item,
544- AttrVec :: new ( ) ,
545- None ,
546- ) ) ;
537+ let constructor = self . arena . alloc ( self . expr_lang_item_path ( method_span, lang_item, None ) ) ;
547538 self . expr_call ( overall_span, constructor, std:: slice:: from_ref ( expr) )
548539 }
549540
@@ -715,12 +706,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
715706 // E0700 in src/test/ui/self/self_lifetime-async.rs
716707
717708 // `future::identity_future`:
718- let identity_future = self . expr_lang_item_path (
719- unstable_span,
720- hir:: LangItem :: IdentityFuture ,
721- AttrVec :: new ( ) ,
722- None ,
723- ) ;
709+ let identity_future =
710+ self . expr_lang_item_path ( unstable_span, hir:: LangItem :: IdentityFuture , None ) ;
724711
725712 // `future::identity_future(generator)`:
726713 hir:: ExprKind :: Call ( self . arena . alloc ( identity_future) , arena_vec ! [ self ; generator] )
@@ -817,7 +804,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
817804 let break_x = self . with_loop_scope ( loop_node_id, move |this| {
818805 let expr_break =
819806 hir:: ExprKind :: Break ( this. lower_loop_destination ( None ) , Some ( x_expr) ) ;
820- this. arena . alloc ( this. expr ( gen_future_span, expr_break, AttrVec :: new ( ) ) )
807+ this. arena . alloc ( this. expr ( gen_future_span, expr_break) )
821808 } ) ;
822809 self . arm ( ready_pat, break_x)
823810 } ;
@@ -850,17 +837,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
850837 let yield_expr = self . expr (
851838 span,
852839 hir:: ExprKind :: Yield ( unit, hir:: YieldSource :: Await { expr : Some ( expr_hir_id) } ) ,
853- AttrVec :: new ( ) ,
854840 ) ;
855841 let yield_expr = self . arena . alloc ( yield_expr) ;
856842
857843 if let Some ( task_context_hid) = self . task_context {
858844 let lhs = self . expr_ident ( span, task_context_ident, task_context_hid) ;
859- let assign = self . expr (
860- span,
861- hir:: ExprKind :: Assign ( lhs, yield_expr, self . lower_span ( span) ) ,
862- AttrVec :: new ( ) ,
863- ) ;
845+ let assign =
846+ self . expr ( span, hir:: ExprKind :: Assign ( lhs, yield_expr, self . lower_span ( span) ) ) ;
864847 self . stmt_expr ( span, assign)
865848 } else {
866849 // Use of `await` outside of an async context. Return `yield_expr` so that we can
@@ -1044,7 +1027,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10441027 hir:: AsyncGeneratorKind :: Closure ,
10451028 |this| this. with_new_scopes ( |this| this. lower_expr_mut ( body) ) ,
10461029 ) ;
1047- this. expr ( fn_decl_span, async_body, AttrVec :: new ( ) )
1030+ this. expr ( fn_decl_span, async_body)
10481031 } ) ;
10491032 body_id
10501033 } ) ;
@@ -1304,7 +1287,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13041287 let ident = self . expr_ident ( lhs. span , ident, binding) ;
13051288 let assign =
13061289 hir:: ExprKind :: Assign ( self . lower_expr ( lhs) , ident, self . lower_span ( eq_sign_span) ) ;
1307- let expr = self . expr ( lhs. span , assign, AttrVec :: new ( ) ) ;
1290+ let expr = self . expr ( lhs. span , assign) ;
13081291 assignments. push ( self . stmt_expr ( lhs. span , expr) ) ;
13091292 pat
13101293 }
@@ -1345,8 +1328,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
13451328 let e2 = self . lower_expr_mut ( e2) ;
13461329 let fn_path =
13471330 hir:: QPath :: LangItem ( hir:: LangItem :: RangeInclusiveNew , self . lower_span ( span) , None ) ;
1348- let fn_expr =
1349- self . arena . alloc ( self . expr ( span, hir:: ExprKind :: Path ( fn_path) , AttrVec :: new ( ) ) ) ;
1331+ let fn_expr = self . arena . alloc ( self . expr ( span, hir:: ExprKind :: Path ( fn_path) ) ) ;
13501332 hir:: ExprKind :: Call ( fn_expr, arena_vec ! [ self ; e1, e2] )
13511333 }
13521334
@@ -1518,8 +1500,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15181500
15191501 // `None => break`
15201502 let none_arm = {
1521- let break_expr =
1522- self . with_loop_scope ( e. id , |this| this. expr_break_alloc ( for_span, AttrVec :: new ( ) ) ) ;
1503+ let break_expr = self . with_loop_scope ( e. id , |this| this. expr_break_alloc ( for_span) ) ;
15231504 let pat = self . pat_none ( for_span) ;
15241505 self . arm ( pat, break_expr)
15251506 } ;
@@ -1528,7 +1509,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
15281509 let some_arm = {
15291510 let some_pat = self . pat_some ( pat_span, pat) ;
15301511 let body_block = self . with_loop_scope ( e. id , |this| this. lower_block ( body, false ) ) ;
1531- let body_expr = self . arena . alloc ( self . expr_block ( body_block, AttrVec :: new ( ) ) ) ;
1512+ let body_expr = self . arena . alloc ( self . expr_block ( body_block) ) ;
15321513 self . arm ( some_pat, body_expr)
15331514 } ;
15341515
@@ -1591,7 +1572,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
15911572 // surrounding scope of the `match` since the `match` is not a terminating scope.
15921573 //
15931574 // Also, add the attributes to the outer returned expr node.
1594- self . expr_drop_temps_mut ( for_span, match_expr, e. attrs . clone ( ) )
1575+ let expr = self . expr_drop_temps_mut ( for_span, match_expr) ;
1576+ self . lower_attrs ( expr. hir_id , & e. attrs ) ;
1577+ expr
15951578 }
15961579
15971580 /// Desugar `ExprKind::Try` from: `<expr>?` into:
@@ -1646,12 +1629,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
16461629 let continue_arm = {
16471630 let val_ident = Ident :: with_dummy_span ( sym:: val) ;
16481631 let ( val_pat, val_pat_nid) = self . pat_ident ( span, val_ident) ;
1649- let val_expr = self . arena . alloc ( self . expr_ident_with_attrs (
1650- span,
1651- val_ident,
1652- val_pat_nid,
1653- attrs. clone ( ) ,
1654- ) ) ;
1632+ let val_expr = self . expr_ident ( span, val_ident, val_pat_nid) ;
1633+ self . lower_attrs ( val_expr. hir_id , & attrs) ;
16551634 let continue_pat = self . pat_cf_continue ( unstable_span, val_pat) ;
16561635 self . arm ( continue_pat, val_expr)
16571636 } ;
@@ -1677,15 +1656,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
16771656 hir:: Destination { label : None , target_id } ,
16781657 Some ( from_residual_expr) ,
16791658 ) ,
1680- attrs,
16811659 ) )
16821660 } else {
1683- self . arena . alloc ( self . expr (
1684- try_span,
1685- hir:: ExprKind :: Ret ( Some ( from_residual_expr) ) ,
1686- attrs,
1687- ) )
1661+ self . arena . alloc ( self . expr ( try_span, hir:: ExprKind :: Ret ( Some ( from_residual_expr) ) ) )
16881662 } ;
1663+ self . lower_attrs ( ret_expr. hir_id , & attrs) ;
16891664
16901665 let break_pat = self . pat_cf_break ( try_span, residual_local) ;
16911666 self . arm ( break_pat, ret_expr)
@@ -1750,18 +1725,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
17501725 & mut self ,
17511726 span : Span ,
17521727 expr : & ' hir hir:: Expr < ' hir > ,
1753- attrs : AttrVec ,
17541728 ) -> & ' hir hir:: Expr < ' hir > {
1755- self . arena . alloc ( self . expr_drop_temps_mut ( span, expr, attrs ) )
1729+ self . arena . alloc ( self . expr_drop_temps_mut ( span, expr) )
17561730 }
17571731
17581732 pub ( super ) fn expr_drop_temps_mut (
17591733 & mut self ,
17601734 span : Span ,
17611735 expr : & ' hir hir:: Expr < ' hir > ,
1762- attrs : AttrVec ,
17631736 ) -> hir:: Expr < ' hir > {
1764- self . expr ( span, hir:: ExprKind :: DropTemps ( expr) , attrs )
1737+ self . expr ( span, hir:: ExprKind :: DropTemps ( expr) )
17651738 }
17661739
17671740 fn expr_match (
@@ -1771,29 +1744,25 @@ impl<'hir> LoweringContext<'_, 'hir> {
17711744 arms : & ' hir [ hir:: Arm < ' hir > ] ,
17721745 source : hir:: MatchSource ,
17731746 ) -> hir:: Expr < ' hir > {
1774- self . expr ( span, hir:: ExprKind :: Match ( arg, arms, source) , AttrVec :: new ( ) )
1747+ self . expr ( span, hir:: ExprKind :: Match ( arg, arms, source) )
17751748 }
17761749
1777- fn expr_break ( & mut self , span : Span , attrs : AttrVec ) -> hir:: Expr < ' hir > {
1750+ fn expr_break ( & mut self , span : Span ) -> hir:: Expr < ' hir > {
17781751 let expr_break = hir:: ExprKind :: Break ( self . lower_loop_destination ( None ) , None ) ;
1779- self . expr ( span, expr_break, attrs )
1752+ self . expr ( span, expr_break)
17801753 }
17811754
1782- fn expr_break_alloc ( & mut self , span : Span , attrs : AttrVec ) -> & ' hir hir:: Expr < ' hir > {
1783- let expr_break = self . expr_break ( span, attrs ) ;
1755+ fn expr_break_alloc ( & mut self , span : Span ) -> & ' hir hir:: Expr < ' hir > {
1756+ let expr_break = self . expr_break ( span) ;
17841757 self . arena . alloc ( expr_break)
17851758 }
17861759
17871760 fn expr_mut_addr_of ( & mut self , span : Span , e : & ' hir hir:: Expr < ' hir > ) -> hir:: Expr < ' hir > {
1788- self . expr (
1789- span,
1790- hir:: ExprKind :: AddrOf ( hir:: BorrowKind :: Ref , hir:: Mutability :: Mut , e) ,
1791- AttrVec :: new ( ) ,
1792- )
1761+ self . expr ( span, hir:: ExprKind :: AddrOf ( hir:: BorrowKind :: Ref , hir:: Mutability :: Mut , e) )
17931762 }
17941763
17951764 fn expr_unit ( & mut self , sp : Span ) -> & ' hir hir:: Expr < ' hir > {
1796- self . arena . alloc ( self . expr ( sp, hir:: ExprKind :: Tup ( & [ ] ) , AttrVec :: new ( ) ) )
1765+ self . arena . alloc ( self . expr ( sp, hir:: ExprKind :: Tup ( & [ ] ) ) )
17971766 }
17981767
17991768 fn expr_call_mut (
@@ -1802,7 +1771,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18021771 e : & ' hir hir:: Expr < ' hir > ,
18031772 args : & ' hir [ hir:: Expr < ' hir > ] ,
18041773 ) -> hir:: Expr < ' hir > {
1805- self . expr ( span, hir:: ExprKind :: Call ( e, args) , AttrVec :: new ( ) )
1774+ self . expr ( span, hir:: ExprKind :: Call ( e, args) )
18061775 }
18071776
18081777 fn expr_call (
@@ -1821,8 +1790,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18211790 args : & ' hir [ hir:: Expr < ' hir > ] ,
18221791 hir_id : Option < hir:: HirId > ,
18231792 ) -> hir:: Expr < ' hir > {
1824- let path =
1825- self . arena . alloc ( self . expr_lang_item_path ( span, lang_item, AttrVec :: new ( ) , hir_id) ) ;
1793+ let path = self . arena . alloc ( self . expr_lang_item_path ( span, lang_item, hir_id) ) ;
18261794 self . expr_call_mut ( span, path, args)
18271795 }
18281796
@@ -1840,13 +1808,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
18401808 & mut self ,
18411809 span : Span ,
18421810 lang_item : hir:: LangItem ,
1843- attrs : AttrVec ,
18441811 hir_id : Option < hir:: HirId > ,
18451812 ) -> hir:: Expr < ' hir > {
18461813 self . expr (
18471814 span,
18481815 hir:: ExprKind :: Path ( hir:: QPath :: LangItem ( lang_item, self . lower_span ( span) , hir_id) ) ,
1849- attrs,
18501816 )
18511817 }
18521818
@@ -1860,20 +1826,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
18601826 }
18611827
18621828 pub ( super ) fn expr_ident_mut (
1863- & mut self ,
1864- sp : Span ,
1865- ident : Ident ,
1866- binding : hir:: HirId ,
1867- ) -> hir:: Expr < ' hir > {
1868- self . expr_ident_with_attrs ( sp, ident, binding, AttrVec :: new ( ) )
1869- }
1870-
1871- fn expr_ident_with_attrs (
18721829 & mut self ,
18731830 span : Span ,
18741831 ident : Ident ,
18751832 binding : hir:: HirId ,
1876- attrs : AttrVec ,
18771833 ) -> hir:: Expr < ' hir > {
18781834 let hir_id = self . next_id ( ) ;
18791835 let res = Res :: Local ( binding) ;
@@ -1886,7 +1842,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18861842 } ) ,
18871843 ) ) ;
18881844
1889- self . expr ( span, expr_path, attrs )
1845+ self . expr ( span, expr_path)
18901846 }
18911847
18921848 fn expr_unsafe ( & mut self , expr : & ' hir hir:: Expr < ' hir > ) -> hir:: Expr < ' hir > {
@@ -1905,32 +1861,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
19051861 } ) ,
19061862 None ,
19071863 ) ,
1908- AttrVec :: new ( ) ,
19091864 )
19101865 }
19111866
19121867 fn expr_block_empty ( & mut self , span : Span ) -> & ' hir hir:: Expr < ' hir > {
19131868 let blk = self . block_all ( span, & [ ] , None ) ;
1914- let expr = self . expr_block ( blk, AttrVec :: new ( ) ) ;
1869+ let expr = self . expr_block ( blk) ;
19151870 self . arena . alloc ( expr)
19161871 }
19171872
1918- pub ( super ) fn expr_block (
1919- & mut self ,
1920- b : & ' hir hir:: Block < ' hir > ,
1921- attrs : AttrVec ,
1922- ) -> hir:: Expr < ' hir > {
1923- self . expr ( b. span , hir:: ExprKind :: Block ( b, None ) , attrs)
1873+ pub ( super ) fn expr_block ( & mut self , b : & ' hir hir:: Block < ' hir > ) -> hir:: Expr < ' hir > {
1874+ self . expr ( b. span , hir:: ExprKind :: Block ( b, None ) )
19241875 }
19251876
1926- pub ( super ) fn expr (
1927- & mut self ,
1928- span : Span ,
1929- kind : hir:: ExprKind < ' hir > ,
1930- attrs : AttrVec ,
1931- ) -> hir:: Expr < ' hir > {
1877+ pub ( super ) fn expr ( & mut self , span : Span , kind : hir:: ExprKind < ' hir > ) -> hir:: Expr < ' hir > {
19321878 let hir_id = self . next_id ( ) ;
1933- self . lower_attrs ( hir_id, & attrs) ;
19341879 hir:: Expr { hir_id, kind, span : self . lower_span ( span) }
19351880 }
19361881
0 commit comments