@@ -199,6 +199,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
199
199
ident,
200
200
generics,
201
201
ty,
202
+ body_id,
202
203
expr,
203
204
define_opaque,
204
205
..
@@ -211,7 +212,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
211
212
|this| {
212
213
let ty = this
213
214
. lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
214
- ( ty, this. lower_const_item ( span, expr. as_deref ( ) ) )
215
+ ( ty, this. lower_const_item ( span, body_id . zip ( expr. as_deref ( ) ) ) )
215
216
} ,
216
217
) ;
217
218
self . lower_define_opaque ( hir_id, & define_opaque) ;
@@ -495,21 +496,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
495
496
}
496
497
}
497
498
498
- fn lower_const_item ( & mut self , span : Span , body : Option < & Expr > ) -> hir:: BodyId {
499
- self . lower_const_body ( span, body)
499
+ fn lower_const_item ( & mut self , span : Span , body : Option < ( NodeId , & Expr ) > ) -> hir:: BodyId {
500
+ self . lower_const_body ( span, body. map ( |b| b . 1 ) )
500
501
// TODO: code to add next
501
- // let ct_arg = if self.tcx.features().min_generic_const_args()
502
- // && let Some(expr) = body
503
- // {
502
+ // let mgca = self.tcx.features().min_generic_const_args();
503
+ // let ct_arg = if mgca && let Some((_, expr)) = body {
504
504
// self.try_lower_as_const_path(expr)
505
505
// } else {
506
506
// None
507
507
// };
508
- // let body_id = if body.is_some() && ct_arg.is_none() {
509
- // // TODO: lower as const block instead
510
- // self.lower_const_body(span, body)
508
+ // let body_id = if mgca && ct_arg.is_none() {
509
+ // self.lower_const_body_with_const_block(span, body)
511
510
// } else {
512
- // self.lower_const_body(span, body)
511
+ // self.lower_const_body(span, body.map(|(_, e)| e) )
513
512
// };
514
513
// (body_id, ct_arg)
515
514
}
@@ -809,6 +808,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
809
808
ident,
810
809
generics,
811
810
ty,
811
+ body_id,
812
812
expr,
813
813
define_opaque,
814
814
..
@@ -820,7 +820,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
820
820
|this| {
821
821
let ty = this
822
822
. lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
823
- let body = expr. as_deref ( ) . map ( |e| this. lower_const_item ( i. span , Some ( e) ) ) ;
823
+ let body = expr
824
+ . as_deref ( )
825
+ . map ( |e| this. lower_const_item ( i. span , Some ( ( body_id. unwrap ( ) , e) ) ) ) ;
824
826
hir:: TraitItemKind :: Const ( ty, body)
825
827
} ,
826
828
) ;
@@ -1000,6 +1002,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1000
1002
ident,
1001
1003
generics,
1002
1004
ty,
1005
+ body_id,
1003
1006
expr,
1004
1007
define_opaque,
1005
1008
..
@@ -1013,7 +1016,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
1013
1016
let ty = this
1014
1017
. lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
1015
1018
this. lower_define_opaque ( hir_id, & define_opaque) ;
1016
- let body = this. lower_const_item ( i. span , expr. as_deref ( ) ) ;
1019
+ let body = this. lower_const_item ( i. span , body_id . zip ( expr. as_deref ( ) ) ) ;
1017
1020
hir:: ImplItemKind :: Const ( ty, body)
1018
1021
} ,
1019
1022
) ,
@@ -1290,6 +1293,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
1290
1293
self . lower_fn_body ( decl, contract, |this| this. lower_block_expr ( body) )
1291
1294
}
1292
1295
1296
+ // TODO: add lower_const_body_with_const_block
1297
+
1293
1298
pub ( super ) fn lower_const_body ( & mut self , span : Span , expr : Option < & Expr > ) -> hir:: BodyId {
1294
1299
self . lower_body ( |this| {
1295
1300
(
0 commit comments