@@ -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
@@ -694,12 +685,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
694
685
// E0700 in src/test/ui/self/self_lifetime-async.rs
695
686
696
687
// `future::identity_future`:
697
- let identity_future = self . expr_lang_item_path (
698
- unstable_span,
699
- hir:: LangItem :: IdentityFuture ,
700
- AttrVec :: new ( ) ,
701
- None ,
702
- ) ;
688
+ let identity_future =
689
+ self . expr_lang_item_path ( unstable_span, hir:: LangItem :: IdentityFuture , None ) ;
703
690
704
691
// `future::identity_future(generator)`:
705
692
hir:: ExprKind :: Call ( self . arena . alloc ( identity_future) , arena_vec ! [ self ; generator] )
@@ -802,7 +789,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
802
789
let break_x = self . with_loop_scope ( loop_node_id, move |this| {
803
790
let expr_break =
804
791
hir:: ExprKind :: Break ( this. lower_loop_destination ( None ) , Some ( x_expr) ) ;
805
- this. arena . alloc ( this. expr ( gen_future_span, expr_break, AttrVec :: new ( ) ) )
792
+ this. arena . alloc ( this. expr ( gen_future_span, expr_break) )
806
793
} ) ;
807
794
self . arm ( ready_pat, break_x)
808
795
} ;
@@ -835,17 +822,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
835
822
let yield_expr = self . expr (
836
823
span,
837
824
hir:: ExprKind :: Yield ( unit, hir:: YieldSource :: Await { expr : Some ( expr_hir_id) } ) ,
838
- AttrVec :: new ( ) ,
839
825
) ;
840
826
let yield_expr = self . arena . alloc ( yield_expr) ;
841
827
842
828
if let Some ( task_context_hid) = self . task_context {
843
829
let lhs = self . expr_ident ( span, task_context_ident, task_context_hid) ;
844
- let assign = self . expr (
845
- span,
846
- hir:: ExprKind :: Assign ( lhs, yield_expr, self . lower_span ( span) ) ,
847
- AttrVec :: new ( ) ,
848
- ) ;
830
+ let assign =
831
+ self . expr ( span, hir:: ExprKind :: Assign ( lhs, yield_expr, self . lower_span ( span) ) ) ;
849
832
self . stmt_expr ( span, assign)
850
833
} else {
851
834
// Use of `await` outside of an async context. Return `yield_expr` so that we can
@@ -1029,7 +1012,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1029
1012
hir:: AsyncGeneratorKind :: Closure ,
1030
1013
|this| this. with_new_scopes ( |this| this. lower_expr_mut ( body) ) ,
1031
1014
) ;
1032
- this. expr ( fn_decl_span, async_body, AttrVec :: new ( ) )
1015
+ this. expr ( fn_decl_span, async_body)
1033
1016
} ) ;
1034
1017
body_id
1035
1018
} ) ;
@@ -1289,7 +1272,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1289
1272
let ident = self . expr_ident ( lhs. span , ident, binding) ;
1290
1273
let assign =
1291
1274
hir:: ExprKind :: Assign ( self . lower_expr ( lhs) , ident, self . lower_span ( eq_sign_span) ) ;
1292
- let expr = self . expr ( lhs. span , assign, AttrVec :: new ( ) ) ;
1275
+ let expr = self . expr ( lhs. span , assign) ;
1293
1276
assignments. push ( self . stmt_expr ( lhs. span , expr) ) ;
1294
1277
pat
1295
1278
}
@@ -1330,8 +1313,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1330
1313
let e2 = self . lower_expr_mut ( e2) ;
1331
1314
let fn_path =
1332
1315
hir:: QPath :: LangItem ( hir:: LangItem :: RangeInclusiveNew , self . lower_span ( span) , None ) ;
1333
- let fn_expr =
1334
- self . arena . alloc ( self . expr ( span, hir:: ExprKind :: Path ( fn_path) , AttrVec :: new ( ) ) ) ;
1316
+ let fn_expr = self . arena . alloc ( self . expr ( span, hir:: ExprKind :: Path ( fn_path) ) ) ;
1335
1317
hir:: ExprKind :: Call ( fn_expr, arena_vec ! [ self ; e1, e2] )
1336
1318
}
1337
1319
@@ -1503,8 +1485,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1503
1485
1504
1486
// `None => break`
1505
1487
let none_arm = {
1506
- let break_expr =
1507
- self . with_loop_scope ( e. id , |this| this. expr_break_alloc ( for_span, AttrVec :: new ( ) ) ) ;
1488
+ let break_expr = self . with_loop_scope ( e. id , |this| this. expr_break_alloc ( for_span) ) ;
1508
1489
let pat = self . pat_none ( for_span) ;
1509
1490
self . arm ( pat, break_expr)
1510
1491
} ;
@@ -1513,7 +1494,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1513
1494
let some_arm = {
1514
1495
let some_pat = self . pat_some ( pat_span, pat) ;
1515
1496
let body_block = self . with_loop_scope ( e. id , |this| this. lower_block ( body, false ) ) ;
1516
- let body_expr = self . arena . alloc ( self . expr_block ( body_block, AttrVec :: new ( ) ) ) ;
1497
+ let body_expr = self . arena . alloc ( self . expr_block ( body_block) ) ;
1517
1498
self . arm ( some_pat, body_expr)
1518
1499
} ;
1519
1500
@@ -1576,7 +1557,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
1576
1557
// surrounding scope of the `match` since the `match` is not a terminating scope.
1577
1558
//
1578
1559
// Also, add the attributes to the outer returned expr node.
1579
- self . expr_drop_temps_mut ( for_span, match_expr, e. attrs . clone ( ) )
1560
+ let expr = self . expr_drop_temps_mut ( for_span, match_expr) ;
1561
+ self . lower_attrs ( expr. hir_id , & e. attrs ) ;
1562
+ expr
1580
1563
}
1581
1564
1582
1565
/// Desugar `ExprKind::Try` from: `<expr>?` into:
@@ -1631,12 +1614,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
1631
1614
let continue_arm = {
1632
1615
let val_ident = Ident :: with_dummy_span ( sym:: val) ;
1633
1616
let ( val_pat, val_pat_nid) = self . pat_ident ( span, val_ident) ;
1634
- let val_expr = self . arena . alloc ( self . expr_ident_with_attrs (
1635
- span,
1636
- val_ident,
1637
- val_pat_nid,
1638
- attrs. clone ( ) ,
1639
- ) ) ;
1617
+ let val_expr = self . expr_ident ( span, val_ident, val_pat_nid) ;
1618
+ self . lower_attrs ( val_expr. hir_id , & attrs) ;
1640
1619
let continue_pat = self . pat_cf_continue ( unstable_span, val_pat) ;
1641
1620
self . arm ( continue_pat, val_expr)
1642
1621
} ;
@@ -1662,15 +1641,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
1662
1641
hir:: Destination { label : None , target_id } ,
1663
1642
Some ( from_residual_expr) ,
1664
1643
) ,
1665
- attrs,
1666
1644
) )
1667
1645
} else {
1668
- self . arena . alloc ( self . expr (
1669
- try_span,
1670
- hir:: ExprKind :: Ret ( Some ( from_residual_expr) ) ,
1671
- attrs,
1672
- ) )
1646
+ self . arena . alloc ( self . expr ( try_span, hir:: ExprKind :: Ret ( Some ( from_residual_expr) ) ) )
1673
1647
} ;
1648
+ self . lower_attrs ( ret_expr. hir_id , & attrs) ;
1674
1649
1675
1650
let break_pat = self . pat_cf_break ( try_span, residual_local) ;
1676
1651
self . arm ( break_pat, ret_expr)
@@ -1735,18 +1710,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
1735
1710
& mut self ,
1736
1711
span : Span ,
1737
1712
expr : & ' hir hir:: Expr < ' hir > ,
1738
- attrs : AttrVec ,
1739
1713
) -> & ' hir hir:: Expr < ' hir > {
1740
- self . arena . alloc ( self . expr_drop_temps_mut ( span, expr, attrs ) )
1714
+ self . arena . alloc ( self . expr_drop_temps_mut ( span, expr) )
1741
1715
}
1742
1716
1743
1717
pub ( super ) fn expr_drop_temps_mut (
1744
1718
& mut self ,
1745
1719
span : Span ,
1746
1720
expr : & ' hir hir:: Expr < ' hir > ,
1747
- attrs : AttrVec ,
1748
1721
) -> hir:: Expr < ' hir > {
1749
- self . expr ( span, hir:: ExprKind :: DropTemps ( expr) , attrs )
1722
+ self . expr ( span, hir:: ExprKind :: DropTemps ( expr) )
1750
1723
}
1751
1724
1752
1725
fn expr_match (
@@ -1756,29 +1729,25 @@ impl<'hir> LoweringContext<'_, 'hir> {
1756
1729
arms : & ' hir [ hir:: Arm < ' hir > ] ,
1757
1730
source : hir:: MatchSource ,
1758
1731
) -> hir:: Expr < ' hir > {
1759
- self . expr ( span, hir:: ExprKind :: Match ( arg, arms, source) , AttrVec :: new ( ) )
1732
+ self . expr ( span, hir:: ExprKind :: Match ( arg, arms, source) )
1760
1733
}
1761
1734
1762
- fn expr_break ( & mut self , span : Span , attrs : AttrVec ) -> hir:: Expr < ' hir > {
1735
+ fn expr_break ( & mut self , span : Span ) -> hir:: Expr < ' hir > {
1763
1736
let expr_break = hir:: ExprKind :: Break ( self . lower_loop_destination ( None ) , None ) ;
1764
- self . expr ( span, expr_break, attrs )
1737
+ self . expr ( span, expr_break)
1765
1738
}
1766
1739
1767
- fn expr_break_alloc ( & mut self , span : Span , attrs : AttrVec ) -> & ' hir hir:: Expr < ' hir > {
1768
- let expr_break = self . expr_break ( span, attrs ) ;
1740
+ fn expr_break_alloc ( & mut self , span : Span ) -> & ' hir hir:: Expr < ' hir > {
1741
+ let expr_break = self . expr_break ( span) ;
1769
1742
self . arena . alloc ( expr_break)
1770
1743
}
1771
1744
1772
1745
fn expr_mut_addr_of ( & mut self , span : Span , e : & ' hir hir:: Expr < ' hir > ) -> hir:: Expr < ' hir > {
1773
- self . expr (
1774
- span,
1775
- hir:: ExprKind :: AddrOf ( hir:: BorrowKind :: Ref , hir:: Mutability :: Mut , e) ,
1776
- AttrVec :: new ( ) ,
1777
- )
1746
+ self . expr ( span, hir:: ExprKind :: AddrOf ( hir:: BorrowKind :: Ref , hir:: Mutability :: Mut , e) )
1778
1747
}
1779
1748
1780
1749
fn expr_unit ( & mut self , sp : Span ) -> & ' hir hir:: Expr < ' hir > {
1781
- self . arena . alloc ( self . expr ( sp, hir:: ExprKind :: Tup ( & [ ] ) , AttrVec :: new ( ) ) )
1750
+ self . arena . alloc ( self . expr ( sp, hir:: ExprKind :: Tup ( & [ ] ) ) )
1782
1751
}
1783
1752
1784
1753
fn expr_call_mut (
@@ -1787,7 +1756,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1787
1756
e : & ' hir hir:: Expr < ' hir > ,
1788
1757
args : & ' hir [ hir:: Expr < ' hir > ] ,
1789
1758
) -> hir:: Expr < ' hir > {
1790
- self . expr ( span, hir:: ExprKind :: Call ( e, args) , AttrVec :: new ( ) )
1759
+ self . expr ( span, hir:: ExprKind :: Call ( e, args) )
1791
1760
}
1792
1761
1793
1762
fn expr_call (
@@ -1806,8 +1775,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1806
1775
args : & ' hir [ hir:: Expr < ' hir > ] ,
1807
1776
hir_id : Option < hir:: HirId > ,
1808
1777
) -> hir:: Expr < ' hir > {
1809
- let path =
1810
- self . arena . alloc ( self . expr_lang_item_path ( span, lang_item, AttrVec :: new ( ) , hir_id) ) ;
1778
+ let path = self . arena . alloc ( self . expr_lang_item_path ( span, lang_item, hir_id) ) ;
1811
1779
self . expr_call_mut ( span, path, args)
1812
1780
}
1813
1781
@@ -1825,13 +1793,11 @@ impl<'hir> LoweringContext<'_, 'hir> {
1825
1793
& mut self ,
1826
1794
span : Span ,
1827
1795
lang_item : hir:: LangItem ,
1828
- attrs : AttrVec ,
1829
1796
hir_id : Option < hir:: HirId > ,
1830
1797
) -> hir:: Expr < ' hir > {
1831
1798
self . expr (
1832
1799
span,
1833
1800
hir:: ExprKind :: Path ( hir:: QPath :: LangItem ( lang_item, self . lower_span ( span) , hir_id) ) ,
1834
- attrs,
1835
1801
)
1836
1802
}
1837
1803
@@ -1845,20 +1811,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
1845
1811
}
1846
1812
1847
1813
pub ( super ) fn expr_ident_mut (
1848
- & mut self ,
1849
- sp : Span ,
1850
- ident : Ident ,
1851
- binding : hir:: HirId ,
1852
- ) -> hir:: Expr < ' hir > {
1853
- self . expr_ident_with_attrs ( sp, ident, binding, AttrVec :: new ( ) )
1854
- }
1855
-
1856
- fn expr_ident_with_attrs (
1857
1814
& mut self ,
1858
1815
span : Span ,
1859
1816
ident : Ident ,
1860
1817
binding : hir:: HirId ,
1861
- attrs : AttrVec ,
1862
1818
) -> hir:: Expr < ' hir > {
1863
1819
let hir_id = self . next_id ( ) ;
1864
1820
let res = Res :: Local ( binding) ;
@@ -1871,7 +1827,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1871
1827
} ) ,
1872
1828
) ) ;
1873
1829
1874
- self . expr ( span, expr_path, attrs )
1830
+ self . expr ( span, expr_path)
1875
1831
}
1876
1832
1877
1833
fn expr_unsafe ( & mut self , expr : & ' hir hir:: Expr < ' hir > ) -> hir:: Expr < ' hir > {
@@ -1890,32 +1846,21 @@ impl<'hir> LoweringContext<'_, 'hir> {
1890
1846
} ) ,
1891
1847
None ,
1892
1848
) ,
1893
- AttrVec :: new ( ) ,
1894
1849
)
1895
1850
}
1896
1851
1897
1852
fn expr_block_empty ( & mut self , span : Span ) -> & ' hir hir:: Expr < ' hir > {
1898
1853
let blk = self . block_all ( span, & [ ] , None ) ;
1899
- let expr = self . expr_block ( blk, AttrVec :: new ( ) ) ;
1854
+ let expr = self . expr_block ( blk) ;
1900
1855
self . arena . alloc ( expr)
1901
1856
}
1902
1857
1903
- pub ( super ) fn expr_block (
1904
- & mut self ,
1905
- b : & ' hir hir:: Block < ' hir > ,
1906
- attrs : AttrVec ,
1907
- ) -> hir:: Expr < ' hir > {
1908
- self . expr ( b. span , hir:: ExprKind :: Block ( b, None ) , attrs)
1858
+ pub ( super ) fn expr_block ( & mut self , b : & ' hir hir:: Block < ' hir > ) -> hir:: Expr < ' hir > {
1859
+ self . expr ( b. span , hir:: ExprKind :: Block ( b, None ) )
1909
1860
}
1910
1861
1911
- pub ( super ) fn expr (
1912
- & mut self ,
1913
- span : Span ,
1914
- kind : hir:: ExprKind < ' hir > ,
1915
- attrs : AttrVec ,
1916
- ) -> hir:: Expr < ' hir > {
1862
+ pub ( super ) fn expr ( & mut self , span : Span , kind : hir:: ExprKind < ' hir > ) -> hir:: Expr < ' hir > {
1917
1863
let hir_id = self . next_id ( ) ;
1918
- self . lower_attrs ( hir_id, & attrs) ;
1919
1864
hir:: Expr { hir_id, kind, span : self . lower_span ( span) }
1920
1865
}
1921
1866
0 commit comments