@@ -172,37 +172,41 @@ impl<'hir> LoweringContext<'_, 'hir> {
172172 }
173173 ItemKind :: Static ( box ast:: StaticItem {
174174 ident,
175- ty : t ,
175+ ty,
176176 safety : _,
177177 mutability : m,
178178 expr : e,
179179 define_opaque,
180180 } ) => {
181181 let ident = self . lower_ident ( * ident) ;
182- let ( ty, body_id) =
183- self . lower_const_item ( t, span, e. as_deref ( ) , ImplTraitPosition :: StaticTy ) ;
182+ let ty =
183+ self . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: StaticTy ) ) ;
184+ let body_id = self . lower_const_body ( span, e. as_deref ( ) ) ;
184185 self . lower_define_opaque ( hir_id, define_opaque) ;
185186 hir:: ItemKind :: Static ( * m, ident, ty, body_id)
186187 }
187188 ItemKind :: Const ( box ast:: ConstItem {
188189 ident,
189190 generics,
190191 ty,
191- expr ,
192+ body ,
192193 define_opaque,
193194 ..
194195 } ) => {
195196 let ident = self . lower_ident ( * ident) ;
196- let ( generics, ( ty, body_id ) ) = self . lower_generics (
197+ let ( generics, ( ty, body ) ) = self . lower_generics (
197198 generics,
198199 id,
199200 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
200201 |this| {
201- this. lower_const_item ( ty, span, expr. as_deref ( ) , ImplTraitPosition :: ConstTy )
202+ let ty = this
203+ . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
204+ let body = this. lower_const_item_rhs ( attrs, body. as_ref ( ) , span) ;
205+ ( ty, body)
202206 } ,
203207 ) ;
204208 self . lower_define_opaque ( hir_id, & define_opaque) ;
205- hir:: ItemKind :: Const ( ident, generics, ty, body_id )
209+ hir:: ItemKind :: Const ( ident, generics, ty, body )
206210 }
207211 ItemKind :: Fn ( box Fn {
208212 sig : FnSig { decl, header, span : fn_sig_span } ,
@@ -463,17 +467,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
463467 }
464468 }
465469
466- fn lower_const_item (
467- & mut self ,
468- ty : & Ty ,
469- span : Span ,
470- body : Option < & Expr > ,
471- impl_trait_position : ImplTraitPosition ,
472- ) -> ( & ' hir hir:: Ty < ' hir > , hir:: BodyId ) {
473- let ty = self . lower_ty ( ty, ImplTraitContext :: Disallowed ( impl_trait_position) ) ;
474- ( ty, self . lower_const_body ( span, body) )
475- }
476-
477470 #[ instrument( level = "debug" , skip( self ) ) ]
478471 fn lower_use_tree (
479472 & mut self ,
@@ -808,7 +801,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
808801 ident,
809802 generics,
810803 ty,
811- expr ,
804+ body ,
812805 define_opaque,
813806 ..
814807 } ) => {
@@ -819,14 +812,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
819812 |this| {
820813 let ty = this
821814 . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
822- let body = expr. as_ref ( ) . map ( |x| this. lower_const_body ( i. span , Some ( x) ) ) ;
823-
815+ let body = body
816+ . as_ref ( )
817+ . map ( |body| this. lower_const_item_rhs ( attrs, Some ( body) , i. span ) ) ;
824818 hir:: TraitItemKind :: Const ( ty, body)
825819 } ,
826820 ) ;
827821
828822 if define_opaque. is_some ( ) {
829- if expr . is_some ( ) {
823+ if body . is_some ( ) {
830824 self . lower_define_opaque ( hir_id, & define_opaque) ;
831825 } else {
832826 self . dcx ( ) . span_err (
@@ -836,7 +830,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
836830 }
837831 }
838832
839- ( * ident, generics, kind, expr . is_some ( ) )
833+ ( * ident, generics, kind, body . is_some ( ) )
840834 }
841835 AssocItemKind :: Fn ( box Fn {
842836 sig, ident, generics, body : None , define_opaque, ..
@@ -1021,7 +1015,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10211015 ident,
10221016 generics,
10231017 ty,
1024- expr ,
1018+ body ,
10251019 define_opaque,
10261020 ..
10271021 } ) => (
@@ -1033,8 +1027,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
10331027 |this| {
10341028 let ty = this
10351029 . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
1036- let body = this. lower_const_body ( i. span , expr. as_deref ( ) ) ;
10371030 this. lower_define_opaque ( hir_id, & define_opaque) ;
1031+ let body = this. lower_const_item_rhs ( attrs, body. as_ref ( ) , i. span ) ;
10381032 hir:: ImplItemKind :: Const ( ty, body)
10391033 } ,
10401034 ) ,
0 commit comments