@@ -924,7 +924,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
924924 arena_vec ! [ self ; new_unchecked, get_context] ,
925925 ) ,
926926 } ;
927- self . arena . alloc ( self . expr_unsafe ( call) )
927+ self . arena . alloc ( self . expr_unsafe ( span , call) )
928928 } ;
929929
930930 // `::std::task::Poll::Ready(result) => break result`
@@ -1826,7 +1826,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18261826 arena_vec ! [ self ; iter] ,
18271827 ) ) ;
18281828 // `unsafe { ... }`
1829- let iter = self . arena . alloc ( self . expr_unsafe ( iter) ) ;
1829+ let iter = self . arena . alloc ( self . expr_unsafe ( head_span , iter) ) ;
18301830 let kind = self . make_lowered_await ( head_span, iter, FutureKind :: AsyncIterator ) ;
18311831 self . arena . alloc ( hir:: Expr { hir_id : self . next_id ( ) , kind, span : head_span } )
18321832 }
@@ -1881,7 +1881,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
18811881 arena_vec ! [ self ; iter] ,
18821882 ) ) ;
18831883 // `unsafe { ... }`
1884- let iter = self . arena . alloc ( self . expr_unsafe ( iter) ) ;
1884+ let iter = self . arena . alloc ( self . expr_unsafe ( head_span , iter) ) ;
18851885 let inner_match_expr = self . arena . alloc ( self . expr_match (
18861886 for_span,
18871887 iter,
@@ -2105,18 +2105,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
21052105 self . expr ( sp, hir:: ExprKind :: Lit ( lit) )
21062106 }
21072107
2108- pub ( super ) fn expr_usize ( & mut self , sp : Span , value : usize ) -> hir:: Expr < ' hir > {
2108+ pub ( super ) fn expr_usize ( & mut self , sp : Span , value : u64 ) -> hir:: Expr < ' hir > {
21092109 self . expr_uint ( sp, ast:: UintTy :: Usize , value as u128 )
21102110 }
21112111
2112- pub ( super ) fn expr_u32 ( & mut self , sp : Span , value : u32 ) -> hir:: Expr < ' hir > {
2113- self . expr_uint ( sp, ast:: UintTy :: U32 , value as u128 )
2114- }
2115-
2116- pub ( super ) fn expr_u16 ( & mut self , sp : Span , value : u16 ) -> hir:: Expr < ' hir > {
2117- self . expr_uint ( sp, ast:: UintTy :: U16 , value as u128 )
2118- }
2119-
21202112 pub ( super ) fn expr_str ( & mut self , sp : Span , value : Symbol ) -> hir:: Expr < ' hir > {
21212113 let lit = hir:: Lit {
21222114 span : self . lower_span ( sp) ,
@@ -2256,9 +2248,12 @@ impl<'hir> LoweringContext<'_, 'hir> {
22562248 self . expr ( span, expr_path)
22572249 }
22582250
2259- fn expr_unsafe ( & mut self , expr : & ' hir hir:: Expr < ' hir > ) -> hir:: Expr < ' hir > {
2251+ pub ( super ) fn expr_unsafe (
2252+ & mut self ,
2253+ span : Span ,
2254+ expr : & ' hir hir:: Expr < ' hir > ,
2255+ ) -> hir:: Expr < ' hir > {
22602256 let hir_id = self . next_id ( ) ;
2261- let span = expr. span ;
22622257 self . expr (
22632258 span,
22642259 hir:: ExprKind :: Block (
@@ -2275,6 +2270,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
22752270 )
22762271 }
22772272
2273+ pub ( super ) fn expr_const ( & mut self , span : Span , expr : hir:: Expr < ' hir > ) -> hir:: Expr < ' hir > {
2274+ let node_id = self . next_node_id ( ) ;
2275+ let def_id =
2276+ self . create_def ( node_id, None , DefKind :: InlineConst , DefPathData :: LateAnonConst , span) ;
2277+ let hir_id = self . lower_node_id ( node_id) ;
2278+ let body = self . record_body ( & [ ] , expr) ;
2279+ self . expr ( span, hir:: ExprKind :: ConstBlock ( hir:: ConstBlock { hir_id, def_id, body } ) )
2280+ }
2281+
22782282 fn expr_block_empty ( & mut self , span : Span ) -> & ' hir hir:: Expr < ' hir > {
22792283 let blk = self . block_all ( span, & [ ] , None ) ;
22802284 let expr = self . expr_block ( blk) ;
0 commit comments