@@ -170,15 +170,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
170
170
}
171
171
ItemKind :: Static ( box ast:: StaticItem {
172
172
ident,
173
- ty : t ,
173
+ ty,
174
174
safety : _,
175
175
mutability : m,
176
176
expr : e,
177
177
define_opaque,
178
178
} ) => {
179
179
let ident = self . lower_ident ( * ident) ;
180
- let ( ty, body_id) =
181
- self . lower_const_item ( t, span, e. as_deref ( ) , ImplTraitPosition :: StaticTy ) ;
180
+ let ty =
181
+ self . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: StaticTy ) ) ;
182
+ let body_id = self . lower_const_body ( span, e. as_deref ( ) ) ;
182
183
self . lower_define_opaque ( hir_id, define_opaque) ;
183
184
hir:: ItemKind :: Static ( ident, ty, * m, body_id)
184
185
}
@@ -196,7 +197,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
196
197
id,
197
198
ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
198
199
|this| {
199
- this. lower_const_item ( ty, span, expr. as_deref ( ) , ImplTraitPosition :: ConstTy )
200
+ let ty = this
201
+ . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
202
+ ( ty, this. lower_const_item ( span, expr. as_deref ( ) ) )
200
203
} ,
201
204
) ;
202
205
self . lower_define_opaque ( hir_id, & define_opaque) ;
@@ -480,15 +483,23 @@ impl<'hir> LoweringContext<'_, 'hir> {
480
483
}
481
484
}
482
485
483
- fn lower_const_item (
484
- & mut self ,
485
- ty : & Ty ,
486
- span : Span ,
487
- body : Option < & Expr > ,
488
- impl_trait_position : ImplTraitPosition ,
489
- ) -> ( & ' hir hir:: Ty < ' hir > , hir:: BodyId ) {
490
- let ty = self . lower_ty ( ty, ImplTraitContext :: Disallowed ( impl_trait_position) ) ;
491
- ( ty, self . lower_const_body ( span, body) )
486
+ fn lower_const_item ( & mut self , span : Span , body : Option < & Expr > ) -> hir:: BodyId {
487
+ self . lower_const_body ( span, body)
488
+ // TODO: code to add next
489
+ // let ct_arg = if self.tcx.features().min_generic_const_args()
490
+ // && let Some(expr) = body
491
+ // {
492
+ // self.try_lower_as_const_path(expr)
493
+ // } else {
494
+ // None
495
+ // };
496
+ // let body_id = if body.is_some() && ct_arg.is_none() {
497
+ // // TODO: lower as const block instead
498
+ // self.lower_const_body(span, body)
499
+ // } else {
500
+ // self.lower_const_body(span, body)
501
+ // };
502
+ // (body_id, ct_arg)
492
503
}
493
504
494
505
#[ instrument( level = "debug" , skip( self ) ) ]
@@ -797,8 +808,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
797
808
|this| {
798
809
let ty = this
799
810
. lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
800
- let body = expr. as_ref ( ) . map ( |x| this. lower_const_body ( i. span , Some ( x) ) ) ;
801
-
811
+ let body = expr. as_deref ( ) . map ( |e| this. lower_const_item ( i. span , Some ( e) ) ) ;
802
812
hir:: TraitItemKind :: Const ( ty, body)
803
813
} ,
804
814
) ;
@@ -990,8 +1000,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
990
1000
|this| {
991
1001
let ty = this
992
1002
. lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
993
- let body = this. lower_const_body ( i. span , expr. as_deref ( ) ) ;
994
1003
this. lower_define_opaque ( hir_id, & define_opaque) ;
1004
+ let body = this. lower_const_item ( i. span , expr. as_deref ( ) ) ;
995
1005
hir:: ImplItemKind :: Const ( ty, body)
996
1006
} ,
997
1007
) ,
0 commit comments