@@ -760,31 +760,25 @@ impl<'hir> LoweringContext<'_, 'hir> {
760760
761761 let ( generics, kind) = match i. kind {
762762 AssocItemKind :: Const ( ref ty, ref default) => {
763- let generics = self . lower_generics ( & i. generics , ImplTraitContext :: disallowed ( ) ) ;
764763 let ty = self . lower_ty ( ty, ImplTraitContext :: disallowed ( ) ) ;
765- (
766- generics,
767- hir:: TraitItemKind :: Const (
768- ty,
769- default. as_ref ( ) . map ( |x| self . lower_const_body ( i. span , Some ( x) ) ) ,
770- ) ,
771- )
764+ let body = default. as_ref ( ) . map ( |x| self . lower_const_body ( i. span , Some ( x) ) ) ;
765+ ( hir:: Generics :: empty ( ) , hir:: TraitItemKind :: Const ( ty, body) )
772766 }
773- AssocItemKind :: Fn ( ref sig, None ) => {
767+ AssocItemKind :: Fn ( ref sig, ref generics , None ) => {
774768 let names = self . lower_fn_params_to_names ( & sig. decl ) ;
775769 let ( generics, sig) =
776- self . lower_method_sig ( & i . generics , sig, trait_item_def_id, false , None ) ;
770+ self . lower_method_sig ( generics, sig, trait_item_def_id, false , None ) ;
777771 ( generics, hir:: TraitItemKind :: Method ( sig, hir:: TraitMethod :: Required ( names) ) )
778772 }
779- AssocItemKind :: Fn ( ref sig, Some ( ref body) ) => {
773+ AssocItemKind :: Fn ( ref sig, ref generics , Some ( ref body) ) => {
780774 let body_id = self . lower_fn_body_block ( i. span , & sig. decl , Some ( body) ) ;
781775 let ( generics, sig) =
782- self . lower_method_sig ( & i . generics , sig, trait_item_def_id, false , None ) ;
776+ self . lower_method_sig ( generics, sig, trait_item_def_id, false , None ) ;
783777 ( generics, hir:: TraitItemKind :: Method ( sig, hir:: TraitMethod :: Provided ( body_id) ) )
784778 }
785- AssocItemKind :: TyAlias ( ref bounds, ref default) => {
779+ AssocItemKind :: TyAlias ( ref generics , ref bounds, ref default) => {
786780 let ty = default. as_ref ( ) . map ( |x| self . lower_ty ( x, ImplTraitContext :: disallowed ( ) ) ) ;
787- let generics = self . lower_generics ( & i . generics , ImplTraitContext :: disallowed ( ) ) ;
781+ let generics = self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ;
788782 let kind = hir:: TraitItemKind :: Type (
789783 self . lower_param_bounds ( bounds, ImplTraitContext :: disallowed ( ) ) ,
790784 ty,
@@ -806,10 +800,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
806800 }
807801
808802 fn lower_trait_item_ref ( & mut self , i : & AssocItem ) -> hir:: TraitItemRef {
809- let ( kind, has_default) = match i. kind {
810- AssocItemKind :: Const ( _, ref default) => ( hir:: AssocItemKind :: Const , default. is_some ( ) ) ,
811- AssocItemKind :: TyAlias ( _, ref default) => ( hir:: AssocItemKind :: Type , default. is_some ( ) ) ,
812- AssocItemKind :: Fn ( ref sig, ref default) => {
803+ let ( kind, has_default) = match & i. kind {
804+ AssocItemKind :: Const ( _, default) => ( hir:: AssocItemKind :: Const , default. is_some ( ) ) ,
805+ AssocItemKind :: TyAlias ( _, _ , default) => ( hir:: AssocItemKind :: Type , default. is_some ( ) ) ,
806+ AssocItemKind :: Fn ( sig, _ , default) => {
813807 ( hir:: AssocItemKind :: Method { has_self : sig. decl . has_self ( ) } , default. is_some ( ) )
814808 }
815809 AssocItemKind :: Macro ( ..) => unimplemented ! ( ) ,
@@ -833,21 +827,20 @@ impl<'hir> LoweringContext<'_, 'hir> {
833827
834828 let ( generics, kind) = match i. kind {
835829 AssocItemKind :: Const ( ref ty, ref expr) => {
836- let generics = self . lower_generics ( & i. generics , ImplTraitContext :: disallowed ( ) ) ;
837830 let ty = self . lower_ty ( ty, ImplTraitContext :: disallowed ( ) ) ;
838831 (
839- generics ,
832+ hir :: Generics :: empty ( ) ,
840833 hir:: ImplItemKind :: Const ( ty, self . lower_const_body ( i. span , expr. as_deref ( ) ) ) ,
841834 )
842835 }
843- AssocItemKind :: Fn ( ref sig, ref body) => {
836+ AssocItemKind :: Fn ( ref sig, ref generics , ref body) => {
844837 self . current_item = Some ( i. span ) ;
845838 let asyncness = sig. header . asyncness ;
846839 let body_id =
847840 self . lower_maybe_async_body ( i. span , & sig. decl , asyncness, body. as_deref ( ) ) ;
848841 let impl_trait_return_allow = !self . is_in_trait_impl ;
849842 let ( generics, sig) = self . lower_method_sig (
850- & i . generics ,
843+ generics,
851844 sig,
852845 impl_item_def_id,
853846 impl_trait_return_allow,
@@ -856,8 +849,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
856849
857850 ( generics, hir:: ImplItemKind :: Method ( sig, body_id) )
858851 }
859- AssocItemKind :: TyAlias ( _, ref ty) => {
860- let generics = self . lower_generics ( & i . generics , ImplTraitContext :: disallowed ( ) ) ;
852+ AssocItemKind :: TyAlias ( ref generics , _, ref ty) => {
853+ let generics = self . lower_generics ( generics, ImplTraitContext :: disallowed ( ) ) ;
861854 let kind = match ty {
862855 None => {
863856 let ty = self . arena . alloc ( self . ty ( i. span , hir:: TyKind :: Err ) ) ;
@@ -902,13 +895,13 @@ impl<'hir> LoweringContext<'_, 'hir> {
902895 defaultness : self . lower_defaultness ( i. defaultness , true /* [1] */ ) ,
903896 kind : match & i. kind {
904897 AssocItemKind :: Const ( ..) => hir:: AssocItemKind :: Const ,
905- AssocItemKind :: TyAlias ( _, ty) => {
898+ AssocItemKind :: TyAlias ( _, _ , ty) => {
906899 match ty. as_deref ( ) . and_then ( |ty| ty. kind . opaque_top_hack ( ) ) {
907900 None => hir:: AssocItemKind :: Type ,
908901 Some ( _) => hir:: AssocItemKind :: OpaqueTy ,
909902 }
910903 }
911- AssocItemKind :: Fn ( sig, _) => {
904+ AssocItemKind :: Fn ( sig, _, _ ) => {
912905 hir:: AssocItemKind :: Method { has_self : sig. decl . has_self ( ) }
913906 }
914907 AssocItemKind :: Macro ( ..) => unimplemented ! ( ) ,
0 commit comments