@@ -755,17 +755,17 @@ impl<'hir> LoweringContext<'_, 'hir> {
755755        let  hir_id = self . lower_node_id ( i. id ) ; 
756756        let  trait_item_def_id = hir_id. expect_owner ( ) ; 
757757
758-         let  ( generics,  kind)  = match  i. kind  { 
758+         let  ( generics,  kind,  has_default )  = match  i. kind  { 
759759            AssocItemKind :: Const ( _,  ref  ty,  ref  default)  => { 
760760                let  ty = self . lower_ty ( ty,  ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ; 
761761                let  body = default. as_ref ( ) . map ( |x| self . lower_const_body ( i. span ,  Some ( x) ) ) ; 
762-                 ( hir:: Generics :: empty ( ) ,  hir:: TraitItemKind :: Const ( ty,  body) ) 
762+                 ( hir:: Generics :: empty ( ) ,  hir:: TraitItemKind :: Const ( ty,  body) ,  body . is_some ( ) ) 
763763            } 
764764            AssocItemKind :: Fn ( box  Fn  {  ref  sig,  ref  generics,  body :  None ,  .. } )  => { 
765765                let  names = self . lower_fn_params_to_names ( & sig. decl ) ; 
766766                let  ( generics,  sig)  =
767767                    self . lower_method_sig ( generics,  sig,  i. id ,  FnDeclKind :: Trait ,  None ) ; 
768-                 ( generics,  hir:: TraitItemKind :: Fn ( sig,  hir:: TraitFn :: Required ( names) ) ) 
768+                 ( generics,  hir:: TraitItemKind :: Fn ( sig,  hir:: TraitFn :: Required ( names) ) ,   false ) 
769769            } 
770770            AssocItemKind :: Fn ( box  Fn  {  ref  sig,  ref  generics,  body :  Some ( ref  body) ,  .. } )  => { 
771771                let  asyncness = sig. header . asyncness ; 
@@ -778,7 +778,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
778778                    FnDeclKind :: Trait , 
779779                    asyncness. opt_return_id ( ) , 
780780                ) ; 
781-                 ( generics,  hir:: TraitItemKind :: Fn ( sig,  hir:: TraitFn :: Provided ( body_id) ) ) 
781+                 ( generics,  hir:: TraitItemKind :: Fn ( sig,  hir:: TraitFn :: Provided ( body_id) ) ,   true ) 
782782            } 
783783            AssocItemKind :: TyAlias ( box TyAlias  { 
784784                ref  generics, 
@@ -789,7 +789,7 @@ impl<'hir> LoweringContext<'_, 'hir> {
789789            } )  => { 
790790                let  mut  generics = generics. clone ( ) ; 
791791                add_ty_alias_where_clause ( & mut  generics,  where_clauses,  false ) ; 
792-                 self . lower_generics ( 
792+                 let   ( generics ,  kind )  =  self . lower_generics ( 
793793                    & generics, 
794794                    i. id , 
795795                    ImplTraitContext :: Disallowed ( ImplTraitPosition :: Generic ) , 
@@ -805,7 +805,8 @@ impl<'hir> LoweringContext<'_, 'hir> {
805805                            ty, 
806806                        ) 
807807                    } , 
808-                 ) 
808+                 ) ; 
809+                 ( generics,  kind,  ty. is_some ( ) ) 
809810            } 
810811            AssocItemKind :: MacCall ( ..)  => panic ! ( "macro item shouldn't exist at this point" ) , 
811812        } ; 
@@ -817,28 +818,25 @@ impl<'hir> LoweringContext<'_, 'hir> {
817818            generics, 
818819            kind, 
819820            span :  self . lower_span ( i. span ) , 
821+             defaultness :  hir:: Defaultness :: Default  {  has_value :  has_default } , 
820822        } ; 
821823        self . arena . alloc ( item) 
822824    } 
823825
824826    fn  lower_trait_item_ref ( & mut  self ,  i :  & AssocItem )  -> hir:: TraitItemRef  { 
825-         let  ( kind,  has_default)  = match  & i. kind  { 
826-             AssocItemKind :: Const ( _,  _,  default)  => ( hir:: AssocItemKind :: Const ,  default. is_some ( ) ) , 
827-             AssocItemKind :: TyAlias ( box TyAlias  {  ty,  .. } )  => { 
828-                 ( hir:: AssocItemKind :: Type ,  ty. is_some ( ) ) 
829-             } 
830-             AssocItemKind :: Fn ( box  Fn  {  sig,  body,  .. } )  => { 
831-                 ( hir:: AssocItemKind :: Fn  {  has_self :  sig. decl . has_self ( )  } ,  body. is_some ( ) ) 
827+         let  kind = match  & i. kind  { 
828+             AssocItemKind :: Const ( ..)  => hir:: AssocItemKind :: Const , 
829+             AssocItemKind :: TyAlias ( ..)  => hir:: AssocItemKind :: Type , 
830+             AssocItemKind :: Fn ( box  Fn  {  sig,  .. } )  => { 
831+                 hir:: AssocItemKind :: Fn  {  has_self :  sig. decl . has_self ( )  } 
832832            } 
833833            AssocItemKind :: MacCall ( ..)  => unimplemented ! ( ) , 
834834        } ; 
835835        let  id = hir:: TraitItemId  {  def_id :  self . local_def_id ( i. id )  } ; 
836-         let  defaultness = hir:: Defaultness :: Default  {  has_value :  has_default } ; 
837836        hir:: TraitItemRef  { 
838837            id, 
839838            ident :  self . lower_ident ( i. ident ) , 
840839            span :  self . lower_span ( i. span ) , 
841-             defaultness, 
842840            kind, 
843841        } 
844842    } 
@@ -849,6 +847,10 @@ impl<'hir> LoweringContext<'_, 'hir> {
849847    } 
850848
851849    fn  lower_impl_item ( & mut  self ,  i :  & AssocItem )  -> & ' hir  hir:: ImplItem < ' hir >  { 
850+         // Since `default impl` is not yet implemented, this is always true in impls. 
851+         let  has_value = true ; 
852+         let  ( defaultness,  _)  = self . lower_defaultness ( i. kind . defaultness ( ) ,  has_value) ; 
853+ 
852854        let  ( generics,  kind)  = match  & i. kind  { 
853855            AssocItemKind :: Const ( _,  ty,  expr)  => { 
854856                let  ty = self . lower_ty ( ty,  ImplTraitContext :: Disallowed ( ImplTraitPosition :: Type ) ) ; 
@@ -903,19 +905,16 @@ impl<'hir> LoweringContext<'_, 'hir> {
903905            kind, 
904906            vis_span :  self . lower_span ( i. vis . span ) , 
905907            span :  self . lower_span ( i. span ) , 
908+             defaultness, 
906909        } ; 
907910        self . arena . alloc ( item) 
908911    } 
909912
910913    fn  lower_impl_item_ref ( & mut  self ,  i :  & AssocItem )  -> hir:: ImplItemRef  { 
911-         // Since `default impl` is not yet implemented, this is always true in impls. 
912-         let  has_value = true ; 
913-         let  ( defaultness,  _)  = self . lower_defaultness ( i. kind . defaultness ( ) ,  has_value) ; 
914914        hir:: ImplItemRef  { 
915915            id :  hir:: ImplItemId  {  def_id :  self . local_def_id ( i. id )  } , 
916916            ident :  self . lower_ident ( i. ident ) , 
917917            span :  self . lower_span ( i. span ) , 
918-             defaultness, 
919918            kind :  match  & i. kind  { 
920919                AssocItemKind :: Const ( ..)  => hir:: AssocItemKind :: Const , 
921920                AssocItemKind :: TyAlias ( ..)  => hir:: AssocItemKind :: Type , 
0 commit comments