@@ -121,12 +121,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
121121 LitKind :: Err
122122 }
123123 } ;
124- hir:: ExprKind :: Lit ( respan ( self . lower_span ( e. span ) , lit_kind) )
124+ let lit = self . arena . alloc ( respan ( self . lower_span ( e. span ) , lit_kind) ) ;
125+ hir:: ExprKind :: Lit ( lit)
126+ }
127+ ExprKind :: IncludedBytes ( bytes) => {
128+ let lit = self . arena . alloc ( respan (
129+ self . lower_span ( e. span ) ,
130+ LitKind :: ByteStr ( bytes. clone ( ) , StrStyle :: Cooked ) ,
131+ ) ) ;
132+ hir:: ExprKind :: Lit ( lit)
125133 }
126- ExprKind :: IncludedBytes ( bytes) => hir:: ExprKind :: Lit ( respan (
127- self . lower_span ( e. span ) ,
128- LitKind :: ByteStr ( bytes. clone ( ) , StrStyle :: Cooked ) ,
129- ) ) ,
130134 ExprKind :: Cast ( expr, ty) => {
131135 let expr = self . lower_expr ( expr) ;
132136 let ty =
@@ -1746,40 +1750,31 @@ impl<'hir> LoweringContext<'_, 'hir> {
17461750 }
17471751
17481752 pub ( super ) fn expr_usize ( & mut self , sp : Span , value : usize ) -> hir:: Expr < ' hir > {
1749- self . expr (
1750- sp,
1751- hir:: ExprKind :: Lit ( hir:: Lit {
1752- span : sp,
1753- node : ast:: LitKind :: Int (
1754- value as u128 ,
1755- ast:: LitIntType :: Unsigned ( ast:: UintTy :: Usize ) ,
1756- ) ,
1757- } ) ,
1758- )
1753+ let lit = self . arena . alloc ( hir:: Lit {
1754+ span : sp,
1755+ node : ast:: LitKind :: Int ( value as u128 , ast:: LitIntType :: Unsigned ( ast:: UintTy :: Usize ) ) ,
1756+ } ) ;
1757+ self . expr ( sp, hir:: ExprKind :: Lit ( lit) )
17591758 }
17601759
17611760 pub ( super ) fn expr_u32 ( & mut self , sp : Span , value : u32 ) -> hir:: Expr < ' hir > {
1762- self . expr (
1763- sp,
1764- hir:: ExprKind :: Lit ( hir:: Lit {
1765- span : sp,
1766- node : ast:: LitKind :: Int ( value. into ( ) , ast:: LitIntType :: Unsigned ( ast:: UintTy :: U32 ) ) ,
1767- } ) ,
1768- )
1761+ let lit = self . arena . alloc ( hir:: Lit {
1762+ span : sp,
1763+ node : ast:: LitKind :: Int ( value. into ( ) , ast:: LitIntType :: Unsigned ( ast:: UintTy :: U32 ) ) ,
1764+ } ) ;
1765+ self . expr ( sp, hir:: ExprKind :: Lit ( lit) )
17691766 }
17701767
17711768 pub ( super ) fn expr_char ( & mut self , sp : Span , value : char ) -> hir:: Expr < ' hir > {
1772- self . expr ( sp, hir:: ExprKind :: Lit ( hir:: Lit { span : sp, node : ast:: LitKind :: Char ( value) } ) )
1769+ let lit = self . arena . alloc ( hir:: Lit { span : sp, node : ast:: LitKind :: Char ( value) } ) ;
1770+ self . expr ( sp, hir:: ExprKind :: Lit ( lit) )
17731771 }
17741772
17751773 pub ( super ) fn expr_str ( & mut self , sp : Span , value : Symbol ) -> hir:: Expr < ' hir > {
1776- self . expr (
1777- sp,
1778- hir:: ExprKind :: Lit ( hir:: Lit {
1779- span : sp,
1780- node : ast:: LitKind :: Str ( value, ast:: StrStyle :: Cooked ) ,
1781- } ) ,
1782- )
1774+ let lit = self
1775+ . arena
1776+ . alloc ( hir:: Lit { span : sp, node : ast:: LitKind :: Str ( value, ast:: StrStyle :: Cooked ) } ) ;
1777+ self . expr ( sp, hir:: ExprKind :: Lit ( lit) )
17831778 }
17841779
17851780 pub ( super ) fn expr_call_mut (
0 commit comments