@@ -170,37 +170,36 @@ 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 {
186- ident,
187- generics,
188- ty,
189- expr,
190- define_opaque,
191- ..
187+ ident, generics, ty, rhs, define_opaque, ..
192188 } ) => {
193189 let ident = self . lower_ident ( * ident) ;
194- let ( generics, ( ty, body_id ) ) = self . lower_generics (
190+ let ( generics, ( ty, rhs ) ) = self . lower_generics (
195191 generics,
196192 id,
197193 ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
198194 |this| {
199- this. lower_const_item ( ty, span, expr. as_deref ( ) , ImplTraitPosition :: ConstTy )
195+ let ty = this
196+ . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
197+ let rhs = this. lower_const_item_rhs ( attrs, rhs. as_ref ( ) , span) ;
198+ ( ty, rhs)
200199 } ,
201200 ) ;
202201 self . lower_define_opaque ( hir_id, & define_opaque) ;
203- hir:: ItemKind :: Const ( ident, generics, ty, body_id )
202+ hir:: ItemKind :: Const ( ident, generics, ty, rhs )
204203 }
205204 ItemKind :: Fn ( box Fn {
206205 sig : FnSig { decl, header, span : fn_sig_span } ,
@@ -462,17 +461,6 @@ impl<'hir> LoweringContext<'_, 'hir> {
462461 }
463462 }
464463
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-
476464 #[ instrument( level = "debug" , skip( self ) ) ]
477465 fn lower_use_tree (
478466 & mut self ,
@@ -804,12 +792,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
804792
805793 let ( ident, generics, kind, has_default) = match & i. kind {
806794 AssocItemKind :: Const ( box ConstItem {
807- ident,
808- generics,
809- ty,
810- expr,
811- define_opaque,
812- ..
795+ ident, generics, ty, rhs, define_opaque, ..
813796 } ) => {
814797 let ( generics, kind) = self . lower_generics (
815798 generics,
@@ -818,14 +801,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
818801 |this| {
819802 let ty = this
820803 . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
821- let body = expr. as_ref ( ) . map ( |x| this. lower_const_body ( i. span , Some ( x) ) ) ;
822-
823- hir:: TraitItemKind :: Const ( ty, body)
804+ let rhs = rhs
805+ . as_ref ( )
806+ . map ( |rhs| this. lower_const_item_rhs ( attrs, Some ( rhs) , i. span ) ) ;
807+ hir:: TraitItemKind :: Const ( ty, rhs)
824808 } ,
825809 ) ;
826810
827811 if define_opaque. is_some ( ) {
828- if expr . is_some ( ) {
812+ if rhs . is_some ( ) {
829813 self . lower_define_opaque ( hir_id, & define_opaque) ;
830814 } else {
831815 self . dcx ( ) . span_err (
@@ -835,7 +819,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
835819 }
836820 }
837821
838- ( * ident, generics, kind, expr . is_some ( ) )
822+ ( * ident, generics, kind, rhs . is_some ( ) )
839823 }
840824 AssocItemKind :: Fn ( box Fn {
841825 sig, ident, generics, body : None , define_opaque, ..
@@ -1022,12 +1006,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
10221006
10231007 let ( ident, ( generics, kind) ) = match & i. kind {
10241008 AssocItemKind :: Const ( box ConstItem {
1025- ident,
1026- generics,
1027- ty,
1028- expr,
1029- define_opaque,
1030- ..
1009+ ident, generics, ty, rhs, define_opaque, ..
10311010 } ) => (
10321011 * ident,
10331012 self . lower_generics (
@@ -1037,9 +1016,9 @@ impl<'hir> LoweringContext<'_, 'hir> {
10371016 |this| {
10381017 let ty = this
10391018 . lower_ty ( ty, ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
1040- let body = this. lower_const_body ( i. span , expr. as_deref ( ) ) ;
10411019 this. lower_define_opaque ( hir_id, & define_opaque) ;
1042- hir:: ImplItemKind :: Const ( ty, body)
1020+ let rhs = this. lower_const_item_rhs ( attrs, rhs. as_ref ( ) , i. span ) ;
1021+ hir:: ImplItemKind :: Const ( ty, rhs)
10431022 } ,
10441023 ) ,
10451024 ) ,
0 commit comments