@@ -182,15 +182,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
182
182
}
183
183
ItemKind :: Static ( box ast:: StaticItem {
184
184
ident,
185
- ty : t ,
185
+ ty,
186
186
safety : _,
187
187
mutability : m,
188
188
expr : e,
189
189
define_opaque,
190
190
} ) => {
191
191
let ident = self . lower_ident ( * ident) ;
192
- let ( ty, body_id) =
193
- self . lower_const_item ( t, span, e. as_deref ( ) , ImplTraitPosition :: StaticTy ) ;
192
+ let ty =
193
+ self . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: StaticTy ) ) ;
194
+ let body_id = self . lower_const_body ( span, e. as_deref ( ) ) ;
194
195
self . lower_define_opaque ( hir_id, define_opaque) ;
195
196
hir:: ItemKind :: Static ( ident, ty, * m, body_id)
196
197
}
@@ -208,7 +209,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
208
209
id,
209
210
ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
210
211
|this| {
211
- this. lower_const_item ( ty, span, expr. as_deref ( ) , ImplTraitPosition :: ConstTy )
212
+ let ty = this
213
+ . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
214
+ ( ty, this. lower_const_item ( span, expr. as_deref ( ) ) )
212
215
} ,
213
216
) ;
214
217
self . lower_define_opaque ( hir_id, & define_opaque) ;
@@ -492,15 +495,23 @@ impl<'hir> LoweringContext<'_, 'hir> {
492
495
}
493
496
}
494
497
495
- fn lower_const_item (
496
- & mut self ,
497
- ty : & Ty ,
498
- span : Span ,
499
- body : Option < & Expr > ,
500
- impl_trait_position : ImplTraitPosition ,
501
- ) -> ( & ' hir hir:: Ty < ' hir > , hir:: BodyId ) {
502
- let ty = self . lower_ty ( ty, ImplTraitContext :: Disallowed ( impl_trait_position) ) ;
503
- ( ty, self . lower_const_body ( span, body) )
498
+ fn lower_const_item ( & mut self , span : Span , body : Option < & Expr > ) -> hir:: BodyId {
499
+ self . lower_const_body ( span, body)
500
+ // TODO: code to add next
501
+ // let ct_arg = if self.tcx.features().min_generic_const_args()
502
+ // && let Some(expr) = body
503
+ // {
504
+ // self.try_lower_as_const_path(expr)
505
+ // } else {
506
+ // None
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)
511
+ // } else {
512
+ // self.lower_const_body(span, body)
513
+ // };
514
+ // (body_id, ct_arg)
504
515
}
505
516
506
517
#[ instrument( level = "debug" , skip( self ) ) ]
@@ -809,8 +820,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
809
820
|this| {
810
821
let ty = this
811
822
. lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
812
- let body = expr. as_ref ( ) . map ( |x| this. lower_const_body ( i. span , Some ( x) ) ) ;
813
-
823
+ let body = expr. as_deref ( ) . map ( |e| this. lower_const_item ( i. span , Some ( e) ) ) ;
814
824
hir:: TraitItemKind :: Const ( ty, body)
815
825
} ,
816
826
) ;
@@ -1002,8 +1012,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
1002
1012
|this| {
1003
1013
let ty = this
1004
1014
. lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
1005
- let body = this. lower_const_body ( i. span , expr. as_deref ( ) ) ;
1006
1015
this. lower_define_opaque ( hir_id, & define_opaque) ;
1016
+ let body = this. lower_const_item ( i. span , expr. as_deref ( ) ) ;
1007
1017
hir:: ImplItemKind :: Const ( ty, body)
1008
1018
} ,
1009
1019
) ,
0 commit comments