@@ -199,6 +199,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
199199 ident,
200200 generics,
201201 ty,
202+ body_id,
202203 expr,
203204 define_opaque,
204205 ..
@@ -211,7 +212,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
211212 |this| {
212213 let ty = this
213214 . 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 ( ) ) ) )
215216 } ,
216217 ) ;
217218 self . lower_define_opaque ( hir_id, & define_opaque) ;
@@ -495,21 +496,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
495496 }
496497 }
497498
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 ) )
500501 // 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 {
504504 // self.try_lower_as_const_path(expr)
505505 // } else {
506506 // None
507507 // };
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)
511510 // } else {
512- // self.lower_const_body(span, body)
511+ // self.lower_const_body(span, body.map(|(_, e)| e) )
513512 // };
514513 // (body_id, ct_arg)
515514 }
@@ -809,6 +808,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
809808 ident,
810809 generics,
811810 ty,
811+ body_id,
812812 expr,
813813 define_opaque,
814814 ..
@@ -820,7 +820,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
820820 |this| {
821821 let ty = this
822822 . 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) ) ) ) ;
824826 hir:: TraitItemKind :: Const ( ty, body)
825827 } ,
826828 ) ;
@@ -1000,6 +1002,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10001002 ident,
10011003 generics,
10021004 ty,
1005+ body_id,
10031006 expr,
10041007 define_opaque,
10051008 ..
@@ -1013,7 +1016,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10131016 let ty = this
10141017 . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
10151018 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 ( ) ) ) ;
10171020 hir:: ImplItemKind :: Const ( ty, body)
10181021 } ,
10191022 ) ,
@@ -1290,6 +1293,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
12901293 self . lower_fn_body ( decl, contract, |this| this. lower_block_expr ( body) )
12911294 }
12921295
1296+ // TODO: add lower_const_body_with_const_block
1297+
12931298 pub ( super ) fn lower_const_body ( & mut self , span : Span , expr : Option < & Expr > ) -> hir:: BodyId {
12941299 self . lower_body ( |this| {
12951300 (
0 commit comments