@@ -436,18 +436,14 @@ impl<'hir> LoweringContext<'_, 'hir> {
436
436
let lhs = self . lower_cond ( lhs) ;
437
437
let rhs = self . lower_cond ( rhs) ;
438
438
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) ) )
444
440
}
445
441
ExprKind :: Let ( ..) => self . lower_expr ( cond) ,
446
442
_ => {
447
443
let cond = self . lower_expr ( cond) ;
448
444
let reason = DesugaringKind :: CondTemporary ;
449
445
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)
451
447
}
452
448
}
453
449
}
@@ -477,12 +473,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
477
473
) -> hir:: ExprKind < ' hir > {
478
474
let lowered_cond = self . with_loop_condition_scope ( |t| t. lower_cond ( cond) ) ;
479
475
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) ;
481
477
let stmt_break = self . stmt_expr ( span, expr_break) ;
482
478
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) ) ;
484
480
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) ;
486
482
let block = self . block_expr ( self . arena . alloc ( if_expr) ) ;
487
483
let span = self . lower_span ( span. with_hi ( cond. span . hi ( ) ) ) ;
488
484
let opt_label = self . lower_label ( opt_label) ;
@@ -538,12 +534,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
538
534
expr : & ' hir hir:: Expr < ' hir > ,
539
535
overall_span : Span ,
540
536
) -> & ' 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 ) ) ;
547
538
self . expr_call ( overall_span, constructor, std:: slice:: from_ref ( expr) )
548
539
}
549
540
@@ -715,12 +706,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
715
706
// E0700 in src/test/ui/self/self_lifetime-async.rs
716
707
717
708
// `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 ) ;
724
711
725
712
// `future::identity_future(generator)`:
726
713
hir:: ExprKind :: Call ( self . arena . alloc ( identity_future) , arena_vec ! [ self ; generator] )
@@ -817,7 +804,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
817
804
let break_x = self . with_loop_scope ( loop_node_id, move |this| {
818
805
let expr_break =
819
806
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) )
821
808
} ) ;
822
809
self . arm ( ready_pat, break_x)
823
810
} ;
@@ -850,17 +837,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
850
837
let yield_expr = self . expr (
851
838
span,
852
839
hir:: ExprKind :: Yield ( unit, hir:: YieldSource :: Await { expr : Some ( expr_hir_id) } ) ,
853
- AttrVec :: new ( ) ,
854
840
) ;
855
841
let yield_expr = self . arena . alloc ( yield_expr) ;
856
842
857
843
if let Some ( task_context_hid) = self . task_context {
858
844
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) ) ) ;
864
847
self . stmt_expr ( span, assign)
865
848
} else {
866
849
// Use of `await` outside of an async context. Return `yield_expr` so that we can
@@ -1044,7 +1027,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1044
1027
hir:: AsyncGeneratorKind :: Closure ,
1045
1028
|this| this. with_new_scopes ( |this| this. lower_expr_mut ( body) ) ,
1046
1029
) ;
1047
- this. expr ( fn_decl_span, async_body, AttrVec :: new ( ) )
1030
+ this. expr ( fn_decl_span, async_body)
1048
1031
} ) ;
1049
1032
body_id
1050
1033
} ) ;
@@ -1304,7 +1287,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1304
1287
let ident = self . expr_ident ( lhs. span , ident, binding) ;
1305
1288
let assign =
1306
1289
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) ;
1308
1291
assignments. push ( self . stmt_expr ( lhs. span , expr) ) ;
1309
1292
pat
1310
1293
}
@@ -1345,8 +1328,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1345
1328
let e2 = self . lower_expr_mut ( e2) ;
1346
1329
let fn_path =
1347
1330
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) ) ) ;
1350
1332
hir:: ExprKind :: Call ( fn_expr, arena_vec ! [ self ; e1, e2] )
1351
1333
}
1352
1334
@@ -1518,8 +1500,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1518
1500
1519
1501
// `None => break`
1520
1502
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) ) ;
1523
1504
let pat = self . pat_none ( for_span) ;
1524
1505
self . arm ( pat, break_expr)
1525
1506
} ;
@@ -1528,7 +1509,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1528
1509
let some_arm = {
1529
1510
let some_pat = self . pat_some ( pat_span, pat) ;
1530
1511
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) ) ;
1532
1513
self . arm ( some_pat, body_expr)
1533
1514
} ;
1534
1515
@@ -1591,7 +1572,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
1591
1572
// surrounding scope of the `match` since the `match` is not a terminating scope.
1592
1573
//
1593
1574
// 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
1595
1578
}
1596
1579
1597
1580
/// Desugar `ExprKind::Try` from: `<expr>?` into:
@@ -1646,12 +1629,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
1646
1629
let continue_arm = {
1647
1630
let val_ident = Ident :: with_dummy_span ( sym:: val) ;
1648
1631
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) ;
1655
1634
let continue_pat = self . pat_cf_continue ( unstable_span, val_pat) ;
1656
1635
self . arm ( continue_pat, val_expr)
1657
1636
} ;
@@ -1677,15 +1656,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
1677
1656
hir:: Destination { label : None , target_id } ,
1678
1657
Some ( from_residual_expr) ,
1679
1658
) ,
1680
- attrs,
1681
1659
) )
1682
1660
} 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) ) ) )
1688
1662
} ;
1663
+ self . lower_attrs ( ret_expr. hir_id , & attrs) ;
1689
1664
1690
1665
let break_pat = self . pat_cf_break ( try_span, residual_local) ;
1691
1666
self . arm ( break_pat, ret_expr)
@@ -1750,18 +1725,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
1750
1725
& mut self ,
1751
1726
span : Span ,
1752
1727
expr : & ' hir hir:: Expr < ' hir > ,
1753
- attrs : AttrVec ,
1754
1728
) -> & ' 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) )
1756
1730
}
1757
1731
1758
1732
pub ( super ) fn expr_drop_temps_mut (
1759
1733
& mut self ,
1760
1734
span : Span ,
1761
1735
expr : & ' hir hir:: Expr < ' hir > ,
1762
- attrs : AttrVec ,
1763
1736
) -> hir:: Expr < ' hir > {
1764
- self . expr ( span, hir:: ExprKind :: DropTemps ( expr) , attrs )
1737
+ self . expr ( span, hir:: ExprKind :: DropTemps ( expr) )
1765
1738
}
1766
1739
1767
1740
fn expr_match (
@@ -1771,29 +1744,25 @@ impl<'hir> LoweringContext<'_, 'hir> {
1771
1744
arms : & ' hir [ hir:: Arm < ' hir > ] ,
1772
1745
source : hir:: MatchSource ,
1773
1746
) -> 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) )
1775
1748
}
1776
1749
1777
- fn expr_break ( & mut self , span : Span , attrs : AttrVec ) -> hir:: Expr < ' hir > {
1750
+ fn expr_break ( & mut self , span : Span ) -> hir:: Expr < ' hir > {
1778
1751
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)
1780
1753
}
1781
1754
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) ;
1784
1757
self . arena . alloc ( expr_break)
1785
1758
}
1786
1759
1787
1760
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) )
1793
1762
}
1794
1763
1795
1764
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 ( & [ ] ) ) )
1797
1766
}
1798
1767
1799
1768
fn expr_call_mut (
@@ -1802,7 +1771,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1802
1771
e : & ' hir hir:: Expr < ' hir > ,
1803
1772
args : & ' hir [ hir:: Expr < ' hir > ] ,
1804
1773
) -> hir:: Expr < ' hir > {
1805
- self . expr ( span, hir:: ExprKind :: Call ( e, args) , AttrVec :: new ( ) )
1774
+ self . expr ( span, hir:: ExprKind :: Call ( e, args) )
1806
1775
}
1807
1776
1808
1777
fn expr_call (
@@ -1821,8 +1790,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1821
1790
args : & ' hir [ hir:: Expr < ' hir > ] ,
1822
1791
hir_id : Option < hir:: HirId > ,
1823
1792
) -> 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) ) ;
1826
1794
self . expr_call_mut ( span, path, args)
1827
1795
}
1828
1796
@@ -1840,13 +1808,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
1840
1808
& mut self ,
1841
1809
span : Span ,
1842
1810
lang_item : hir:: LangItem ,
1843
- attrs : AttrVec ,
1844
1811
hir_id : Option < hir:: HirId > ,
1845
1812
) -> hir:: Expr < ' hir > {
1846
1813
self . expr (
1847
1814
span,
1848
1815
hir:: ExprKind :: Path ( hir:: QPath :: LangItem ( lang_item, self . lower_span ( span) , hir_id) ) ,
1849
- attrs,
1850
1816
)
1851
1817
}
1852
1818
@@ -1860,20 +1826,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
1860
1826
}
1861
1827
1862
1828
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 (
1872
1829
& mut self ,
1873
1830
span : Span ,
1874
1831
ident : Ident ,
1875
1832
binding : hir:: HirId ,
1876
- attrs : AttrVec ,
1877
1833
) -> hir:: Expr < ' hir > {
1878
1834
let hir_id = self . next_id ( ) ;
1879
1835
let res = Res :: Local ( binding) ;
@@ -1886,7 +1842,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1886
1842
} ) ,
1887
1843
) ) ;
1888
1844
1889
- self . expr ( span, expr_path, attrs )
1845
+ self . expr ( span, expr_path)
1890
1846
}
1891
1847
1892
1848
fn expr_unsafe ( & mut self , expr : & ' hir hir:: Expr < ' hir > ) -> hir:: Expr < ' hir > {
@@ -1905,32 +1861,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
1905
1861
} ) ,
1906
1862
None ,
1907
1863
) ,
1908
- AttrVec :: new ( ) ,
1909
1864
)
1910
1865
}
1911
1866
1912
1867
fn expr_block_empty ( & mut self , span : Span ) -> & ' hir hir:: Expr < ' hir > {
1913
1868
let blk = self . block_all ( span, & [ ] , None ) ;
1914
- let expr = self . expr_block ( blk, AttrVec :: new ( ) ) ;
1869
+ let expr = self . expr_block ( blk) ;
1915
1870
self . arena . alloc ( expr)
1916
1871
}
1917
1872
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 ) )
1924
1875
}
1925
1876
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 > {
1932
1878
let hir_id = self . next_id ( ) ;
1933
- self . lower_attrs ( hir_id, & attrs) ;
1934
1879
hir:: Expr { hir_id, kind, span : self . lower_span ( span) }
1935
1880
}
1936
1881
0 commit comments