@@ -231,9 +231,15 @@ impl<'hir> LoweringContext<'_, 'hir> {
231
231
let ( ty, body_id) = self . lower_const_item ( t, span, e. as_deref ( ) ) ;
232
232
hir:: ItemKind :: Static ( ty, * m, body_id)
233
233
}
234
- ItemKind :: Const ( box ast:: ConstItem { ty, expr, .. } ) => {
235
- let ( ty, body_id) = self . lower_const_item ( ty, span, expr. as_deref ( ) ) ;
236
- hir:: ItemKind :: Const ( ty, body_id)
234
+ ItemKind :: Const ( box ast:: ConstItem { generics, ty, expr, .. } ) => {
235
+ let ( generics, ( ty, body_id) ) = self . lower_generics (
236
+ generics,
237
+ Const :: No ,
238
+ id,
239
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
240
+ |this| this. lower_const_item ( ty, span, expr. as_deref ( ) ) ,
241
+ ) ;
242
+ hir:: ItemKind :: Const ( ty, generics, body_id)
237
243
}
238
244
ItemKind :: Fn ( box Fn {
239
245
sig : FnSig { decl, header, span : fn_sig_span } ,
@@ -715,11 +721,23 @@ impl<'hir> LoweringContext<'_, 'hir> {
715
721
let trait_item_def_id = hir_id. expect_owner ( ) ;
716
722
717
723
let ( generics, kind, has_default) = match & i. kind {
718
- AssocItemKind :: Const ( box ConstItem { ty, expr, .. } ) => {
719
- let ty =
720
- self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
721
- let body = expr. as_ref ( ) . map ( |x| self . lower_const_body ( i. span , Some ( x) ) ) ;
722
- ( hir:: Generics :: empty ( ) , hir:: TraitItemKind :: Const ( ty, body) , body. is_some ( ) )
724
+ AssocItemKind :: Const ( box ConstItem { generics, ty, expr, .. } ) => {
725
+ let ( generics, kind) = self . lower_generics (
726
+ & generics,
727
+ Const :: No ,
728
+ i. id ,
729
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
730
+ |this| {
731
+ let ty = this. lower_ty (
732
+ ty,
733
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ,
734
+ ) ;
735
+ let body = expr. as_ref ( ) . map ( |x| this. lower_const_body ( i. span , Some ( x) ) ) ;
736
+
737
+ hir:: TraitItemKind :: Const ( ty, body)
738
+ } ,
739
+ ) ;
740
+ ( generics, kind, expr. is_some ( ) )
723
741
}
724
742
AssocItemKind :: Fn ( box Fn { sig, generics, body : None , .. } ) => {
725
743
let asyncness = sig. header . asyncness ;
@@ -817,14 +835,19 @@ impl<'hir> LoweringContext<'_, 'hir> {
817
835
self . lower_attrs ( hir_id, & i. attrs ) ;
818
836
819
837
let ( generics, kind) = match & i. kind {
820
- AssocItemKind :: Const ( box ConstItem { ty, expr, .. } ) => {
821
- let ty =
822
- self . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
823
- (
824
- hir:: Generics :: empty ( ) ,
825
- hir:: ImplItemKind :: Const ( ty, self . lower_const_body ( i. span , expr. as_deref ( ) ) ) ,
826
- )
827
- }
838
+ AssocItemKind :: Const ( box ConstItem { generics, ty, expr, .. } ) => self . lower_generics (
839
+ & generics,
840
+ Const :: No ,
841
+ i. id ,
842
+ & ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) ,
843
+ |this| {
844
+ let ty = this
845
+ . lower_ty ( ty, & ImplTraitContext :: Disallowed ( ImplTraitPosition :: ConstTy ) ) ;
846
+ let body = this. lower_const_body ( i. span , expr. as_deref ( ) ) ;
847
+
848
+ hir:: ImplItemKind :: Const ( ty, body)
849
+ } ,
850
+ ) ,
828
851
AssocItemKind :: Fn ( box Fn { sig, generics, body, .. } ) => {
829
852
self . current_item = Some ( i. span ) ;
830
853
let asyncness = sig. header . asyncness ;
0 commit comments