@@ -170,37 +170,41 @@ impl<'hir> LoweringContext<'_, 'hir> {
170170 }
171171 ItemKind :: Static ( box ast:: StaticItem {
172172 ident,
173- ty : t ,
173+ ty,
174174 safety : _,
175175 mutability : m,
176176 expr : e,
177177 define_opaque,
178178 } ) => {
179179 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 ( ) ) ;
182183 self . lower_define_opaque ( hir_id, define_opaque) ;
183184 hir:: ItemKind :: Static ( * m, ident, ty, body_id)
184185 }
185186 ItemKind :: Const ( box ast:: ConstItem {
186187 ident,
187188 generics,
188189 ty,
189- expr ,
190+ body ,
190191 define_opaque,
191192 ..
192193 } ) => {
193194 let ident = self . lower_ident ( * ident) ;
194- let ( generics, ( ty, body_id ) ) = self . lower_generics (
195+ let ( generics, ( ty, body ) ) = self . lower_generics (
195196 generics,
196197 id,
197198 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
198199 |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+ let body = this. lower_const_item_rhs ( attrs, body. as_ref ( ) , span) ;
203+ ( ty, body)
200204 } ,
201205 ) ;
202206 self . lower_define_opaque ( hir_id, & define_opaque) ;
203- hir:: ItemKind :: Const ( ident, generics, ty, body_id )
207+ hir:: ItemKind :: Const ( ident, generics, ty, body )
204208 }
205209 ItemKind :: Fn ( box Fn {
206210 sig : FnSig { decl, header, span : fn_sig_span } ,
@@ -462,17 +466,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
462466 }
463467 }
464468
465- fn lower_const_item (
466- & mut self ,
467- ty : & Ty ,
468- span : Span ,
469- body : Option < & Expr > ,
470- impl_trait_position : ImplTraitPosition ,
471- ) -> ( & ' hir hir:: Ty < ' hir > , hir:: BodyId ) {
472- let ty = self . lower_ty ( ty, ImplTraitContext :: Disallowed ( impl_trait_position) ) ;
473- ( ty, self . lower_const_body ( span, body) )
474- }
475-
476469 #[ instrument( level = "debug" , skip( self ) ) ]
477470 fn lower_use_tree (
478471 & mut self ,
@@ -807,7 +800,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
807800 ident,
808801 generics,
809802 ty,
810- expr ,
803+ body ,
811804 define_opaque,
812805 ..
813806 } ) => {
@@ -818,14 +811,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
818811 |this| {
819812 let ty = this
820813 . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
821- let body = expr. as_ref ( ) . map ( |x| this. lower_const_body ( i. span , Some ( x) ) ) ;
822-
814+ let body = body
815+ . as_ref ( )
816+ . map ( |body| this. lower_const_item_rhs ( attrs, Some ( body) , i. span ) ) ;
823817 hir:: TraitItemKind :: Const ( ty, body)
824818 } ,
825819 ) ;
826820
827821 if define_opaque. is_some ( ) {
828- if expr . is_some ( ) {
822+ if body . is_some ( ) {
829823 self . lower_define_opaque ( hir_id, & define_opaque) ;
830824 } else {
831825 self . dcx ( ) . span_err (
@@ -835,7 +829,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
835829 }
836830 }
837831
838- ( * ident, generics, kind, expr . is_some ( ) )
832+ ( * ident, generics, kind, body . is_some ( ) )
839833 }
840834 AssocItemKind :: Fn ( box Fn {
841835 sig, ident, generics, body : None , define_opaque, ..
@@ -1025,7 +1019,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10251019 ident,
10261020 generics,
10271021 ty,
1028- expr ,
1022+ body ,
10291023 define_opaque,
10301024 ..
10311025 } ) => (
@@ -1037,8 +1031,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
10371031 |this| {
10381032 let ty = this
10391033 . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
1040- let body = this. lower_const_body ( i. span , expr. as_deref ( ) ) ;
10411034 this. lower_define_opaque ( hir_id, & define_opaque) ;
1035+ let body = this. lower_const_item_rhs ( attrs, body. as_ref ( ) , i. span ) ;
10421036 hir:: ImplItemKind :: Const ( ty, body)
10431037 } ,
10441038 ) ,
0 commit comments