@@ -185,7 +185,7 @@ pub(crate) enum RibKind<'a> {
185185     FnOrCoroutine , 
186186
187187    /// We passed through an item scope. Disallow upvars. 
188-      Item ( HasGenericParams ) , 
188+      Item ( HasGenericParams ,   DefKind ) , 
189189
190190    /// We're in a constant item. Can't refer to dynamic stuff. 
191191     /// 
@@ -225,7 +225,7 @@ impl RibKind<'_> {
225225            | RibKind :: MacroDefinition ( _) 
226226            | RibKind :: ConstParamTy 
227227            | RibKind :: InlineAsmSym  => false , 
228-             RibKind :: AssocItem  | RibKind :: Item ( _ )  | RibKind :: ForwardGenericParamBan  => true , 
228+             RibKind :: AssocItem  | RibKind :: Item ( .. )  | RibKind :: ForwardGenericParamBan  => true , 
229229        } 
230230    } 
231231
@@ -869,11 +869,12 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
869869    } 
870870    fn  visit_foreign_item ( & mut  self ,  foreign_item :  & ' ast  ForeignItem )  { 
871871        self . resolve_doc_links ( & foreign_item. attrs ,  MaybeExported :: Ok ( foreign_item. id ) ) ; 
872+         let  def_kind = self . r . local_def_kind ( foreign_item. id ) ; 
872873        match  foreign_item. kind  { 
873874            ForeignItemKind :: TyAlias ( box TyAlias  {  ref  generics,  .. } )  => { 
874875                self . with_generic_param_rib ( 
875876                    & generics. params , 
876-                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ) , 
877+                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ,  def_kind ) , 
877878                    LifetimeRibKind :: Generics  { 
878879                        binder :  foreign_item. id , 
879880                        kind :  LifetimeBinderKind :: Item , 
@@ -885,7 +886,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
885886            ForeignItemKind :: Fn ( box  Fn  {  ref  generics,  .. } )  => { 
886887                self . with_generic_param_rib ( 
887888                    & generics. params , 
888-                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ) , 
889+                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ,  def_kind ) , 
889890                    LifetimeRibKind :: Generics  { 
890891                        binder :  foreign_item. id , 
891892                        kind :  LifetimeBinderKind :: Function , 
@@ -895,7 +896,7 @@ impl<'a: 'ast, 'ast, 'tcx> Visitor<'ast> for LateResolutionVisitor<'a, '_, 'ast,
895896                ) ; 
896897            } 
897898            ForeignItemKind :: Static ( ..)  => { 
898-                 self . with_static_rib ( |this| { 
899+                 self . with_static_rib ( def_kind ,   |this| { 
899900                    visit:: walk_foreign_item ( this,  foreign_item) ; 
900901                } ) ; 
901902            } 
@@ -2266,10 +2267,11 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
22662267
22672268    fn  resolve_adt ( & mut  self ,  item :  & ' ast  Item ,  generics :  & ' ast  Generics )  { 
22682269        debug ! ( "resolve_adt" ) ; 
2270+         let  kind = self . r . local_def_kind ( item. id ) ; 
22692271        self . with_current_self_item ( item,  |this| { 
22702272            this. with_generic_param_rib ( 
22712273                & generics. params , 
2272-                 RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ) , 
2274+                 RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ,  kind ) , 
22732275                LifetimeRibKind :: Generics  { 
22742276                    binder :  item. id , 
22752277                    kind :  LifetimeBinderKind :: Item , 
@@ -2343,11 +2345,12 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
23432345        let  name = item. ident . name ; 
23442346        debug ! ( "(resolving item) resolving {} ({:?})" ,  name,  item. kind) ; 
23452347
2348+         let  def_kind = self . r . local_def_kind ( item. id ) ; 
23462349        match  item. kind  { 
23472350            ItemKind :: TyAlias ( box TyAlias  {  ref  generics,  .. } )  => { 
23482351                self . with_generic_param_rib ( 
23492352                    & generics. params , 
2350-                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ) , 
2353+                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ,  def_kind ) , 
23512354                    LifetimeRibKind :: Generics  { 
23522355                        binder :  item. id , 
23532356                        kind :  LifetimeBinderKind :: Item , 
@@ -2360,7 +2363,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
23602363            ItemKind :: Fn ( box  Fn  {  ref  generics,  .. } )  => { 
23612364                self . with_generic_param_rib ( 
23622365                    & generics. params , 
2363-                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ) , 
2366+                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ,  def_kind ) , 
23642367                    LifetimeRibKind :: Generics  { 
23652368                        binder :  item. id , 
23662369                        kind :  LifetimeBinderKind :: Function , 
@@ -2399,7 +2402,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
23992402                // Create a new rib for the trait-wide type parameters. 
24002403                self . with_generic_param_rib ( 
24012404                    & generics. params , 
2402-                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ) , 
2405+                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ,  def_kind ) , 
24032406                    LifetimeRibKind :: Generics  { 
24042407                        binder :  item. id , 
24052408                        kind :  LifetimeBinderKind :: Item , 
@@ -2420,7 +2423,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
24202423                // Create a new rib for the trait-wide type parameters. 
24212424                self . with_generic_param_rib ( 
24222425                    & generics. params , 
2423-                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ) , 
2426+                     RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ,  def_kind ) , 
24242427                    LifetimeRibKind :: Generics  { 
24252428                        binder :  item. id , 
24262429                        kind :  LifetimeBinderKind :: Item , 
@@ -2454,7 +2457,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
24542457            } 
24552458
24562459            ItemKind :: Static ( box ast:: StaticItem  {  ref  ty,  ref  expr,  .. } )  => { 
2457-                 self . with_static_rib ( |this| { 
2460+                 self . with_static_rib ( def_kind ,   |this| { 
24582461                    this. with_lifetime_rib ( LifetimeRibKind :: Elided ( LifetimeRes :: Static ) ,  |this| { 
24592462                        this. visit_ty ( ty) ; 
24602463                    } ) ; 
@@ -2469,11 +2472,14 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
24692472            ItemKind :: Const ( box ast:: ConstItem  {  ref  generics,  ref  ty,  ref  expr,  .. } )  => { 
24702473                self . with_generic_param_rib ( 
24712474                    & generics. params , 
2472-                     RibKind :: Item ( if  self . r . tcx . features ( ) . generic_const_items  { 
2473-                         HasGenericParams :: Yes ( generics. span ) 
2474-                     }  else  { 
2475-                         HasGenericParams :: No 
2476-                     } ) , 
2475+                     RibKind :: Item ( 
2476+                         if  self . r . tcx . features ( ) . generic_const_items  { 
2477+                             HasGenericParams :: Yes ( generics. span ) 
2478+                         }  else  { 
2479+                             HasGenericParams :: No 
2480+                         } , 
2481+                         def_kind, 
2482+                     ) , 
24772483                    LifetimeRibKind :: Generics  { 
24782484                        binder :  item. id , 
24792485                        kind :  LifetimeBinderKind :: ConstItem , 
@@ -2558,7 +2564,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
25582564            let  mut  add_bindings_for_ns = |ns| { 
25592565                let  parent_rib = self . ribs [ ns] 
25602566                    . iter ( ) 
2561-                     . rfind ( |r| matches ! ( r. kind,  RibKind :: Item ( _ ) ) ) 
2567+                     . rfind ( |r| matches ! ( r. kind,  RibKind :: Item ( .. ) ) ) 
25622568                    . expect ( "associated item outside of an item" ) ; 
25632569                seen_bindings. extend ( parent_rib. bindings . keys ( ) . map ( |ident| ( * ident,  ident. span ) ) ) ; 
25642570            } ; 
@@ -2693,8 +2699,8 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
26932699        self . label_ribs . pop ( ) ; 
26942700    } 
26952701
2696-     fn  with_static_rib ( & mut  self ,  f :  impl  FnOnce ( & mut  Self ) )  { 
2697-         let  kind = RibKind :: Item ( HasGenericParams :: No ) ; 
2702+     fn  with_static_rib ( & mut  self ,  def_kind :   DefKind ,   f :  impl  FnOnce ( & mut  Self ) )  { 
2703+         let  kind = RibKind :: Item ( HasGenericParams :: No ,  def_kind ) ; 
26982704        self . with_rib ( ValueNS ,  kind,  |this| this. with_rib ( TypeNS ,  kind,  f) ) 
26992705    } 
27002706
@@ -2875,7 +2881,7 @@ impl<'a: 'ast, 'b, 'ast, 'tcx> LateResolutionVisitor<'a, 'b, 'ast, 'tcx> {
28752881        // If applicable, create a rib for the type parameters. 
28762882        self . with_generic_param_rib ( 
28772883            & generics. params , 
2878-             RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ) , 
2884+             RibKind :: Item ( HasGenericParams :: Yes ( generics. span ) ,   self . r . local_def_kind ( item_id ) ) , 
28792885            LifetimeRibKind :: Generics  { 
28802886                span :  generics. span , 
28812887                binder :  item_id, 
0 commit comments