@@ -103,17 +103,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
103
103
104
104
let kind = match & e. kind {
105
105
ExprKind :: Array ( exprs) => hir:: ExprKind :: Array ( self . lower_exprs ( exprs) ) ,
106
- ExprKind :: ConstBlock ( c) => {
107
- let c = self . with_new_scopes ( c. value . span , |this| {
108
- let def_id = this. local_def_id ( c. id ) ;
109
- hir:: ConstBlock {
110
- def_id,
111
- hir_id : this. lower_node_id ( c. id ) ,
112
- body : this. lower_const_body ( c. value . span , Some ( & c. value ) ) ,
113
- }
114
- } ) ;
115
- hir:: ExprKind :: ConstBlock ( c)
116
- }
106
+ ExprKind :: ConstBlock ( c) => hir:: ExprKind :: ConstBlock ( self . lower_const_block ( c) ) ,
117
107
ExprKind :: Repeat ( expr, count) => {
118
108
let expr = self . lower_expr ( expr) ;
119
109
let count = self . lower_array_length_to_const_arg ( count) ;
@@ -154,18 +144,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
154
144
let ohs = self . lower_expr ( ohs) ;
155
145
hir:: ExprKind :: Unary ( op, ohs)
156
146
}
157
- ExprKind :: Lit ( token_lit) => {
158
- let lit_kind = match LitKind :: from_token_lit ( * token_lit) {
159
- Ok ( lit_kind) => lit_kind,
160
- Err ( err) => {
161
- let guar =
162
- report_lit_error ( & self . tcx . sess . psess , err, * token_lit, e. span ) ;
163
- LitKind :: Err ( guar)
164
- }
165
- } ;
166
- let lit = self . arena . alloc ( respan ( self . lower_span ( e. span ) , lit_kind) ) ;
167
- hir:: ExprKind :: Lit ( lit)
168
- }
147
+ ExprKind :: Lit ( token_lit) => hir:: ExprKind :: Lit ( self . lower_lit ( token_lit, e. span ) ) ,
169
148
ExprKind :: IncludedBytes ( bytes) => {
170
149
let lit = self . arena . alloc ( respan (
171
150
self . lower_span ( e. span ) ,
@@ -396,6 +375,32 @@ impl<'hir> LoweringContext<'_, 'hir> {
396
375
} )
397
376
}
398
377
378
+ pub ( crate ) fn lower_const_block ( & mut self , c : & AnonConst ) -> hir:: ConstBlock {
379
+ self . with_new_scopes ( c. value . span , |this| {
380
+ let def_id = this. local_def_id ( c. id ) ;
381
+ hir:: ConstBlock {
382
+ def_id,
383
+ hir_id : this. lower_node_id ( c. id ) ,
384
+ body : this. lower_const_body ( c. value . span , Some ( & c. value ) ) ,
385
+ }
386
+ } )
387
+ }
388
+
389
+ pub ( crate ) fn lower_lit (
390
+ & mut self ,
391
+ token_lit : & token:: Lit ,
392
+ span : Span ,
393
+ ) -> & ' hir Spanned < LitKind > {
394
+ let lit_kind = match LitKind :: from_token_lit ( * token_lit) {
395
+ Ok ( lit_kind) => lit_kind,
396
+ Err ( err) => {
397
+ let guar = report_lit_error ( & self . tcx . sess . psess , err, * token_lit, span) ;
398
+ LitKind :: Err ( guar)
399
+ }
400
+ } ;
401
+ self . arena . alloc ( respan ( self . lower_span ( span) , lit_kind) )
402
+ }
403
+
399
404
fn lower_unop ( & mut self , u : UnOp ) -> hir:: UnOp {
400
405
match u {
401
406
UnOp :: Deref => hir:: UnOp :: Deref ,
0 commit comments