@@ -10,8 +10,8 @@ use std::sync::Arc;
1010
1111use rustc_ast:: visit:: { self , AssocCtxt , Visitor , WalkItemKind } ;
1212use rustc_ast:: {
13- self as ast, AssocItem , AssocItemKind , Block , ConstItem , Delegation , ForeignItem ,
14- ForeignItemKind , Impl , Item , ItemKind , MetaItemKind , NodeId , StaticItem , StmtKind ,
13+ self as ast, AssocItem , AssocItemKind , Block , ConstItem , Delegation , Fn , ForeignItem ,
14+ ForeignItemKind , Impl , Item , ItemKind , MetaItemKind , NodeId , StaticItem , StmtKind , TyAlias ,
1515} ;
1616use rustc_attr_parsing as attr;
1717use rustc_expand:: base:: ResolverExpand ;
@@ -764,8 +764,8 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
764764 ItemKind :: ExternCrate ( orig_name, ident) => {
765765 self . build_reduced_graph_for_extern_crate (
766766 orig_name,
767- ident,
768767 item,
768+ ident,
769769 local_def_id,
770770 vis,
771771 parent,
@@ -797,7 +797,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
797797 | ItemKind :: Static ( box StaticItem { ident, .. } ) => {
798798 self . r . define ( parent, ident, ValueNS , ( res, vis, sp, expansion) ) ;
799799 }
800- ItemKind :: Fn ( box ast :: Fn { ident, .. } ) => {
800+ ItemKind :: Fn ( box Fn { ident, .. } ) => {
801801 self . r . define ( parent, ident, ValueNS , ( res, vis, sp, expansion) ) ;
802802
803803 // Functions introducing procedural macros reserve a slot
@@ -806,7 +806,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
806806 }
807807
808808 // These items live in the type namespace.
809- ItemKind :: TyAlias ( box ast :: TyAlias { ident, .. } ) | ItemKind :: TraitAlias ( ident, ..) => {
809+ ItemKind :: TyAlias ( box TyAlias { ident, .. } ) | ItemKind :: TraitAlias ( ident, ..) => {
810810 self . r . define ( parent, ident, TypeNS , ( res, vis, sp, expansion) ) ;
811811 }
812812
@@ -900,8 +900,8 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
900900 fn build_reduced_graph_for_extern_crate (
901901 & mut self ,
902902 orig_name : Option < Symbol > ,
903- ident : Ident ,
904903 item : & Item ,
904+ ident : Ident ,
905905 local_def_id : LocalDefId ,
906906 vis : ty:: Visibility ,
907907 parent : Module < ' ra > ,
@@ -1362,14 +1362,16 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
13621362 }
13631363
13641364 fn visit_foreign_item ( & mut self , foreign_item : & ' a ForeignItem ) {
1365- if let ForeignItemKind :: MacCall ( _) = foreign_item. kind {
1366- self . visit_invoc_in_module ( foreign_item. id ) ;
1367- return ;
1368- }
1365+ let ident = match foreign_item. kind {
1366+ ForeignItemKind :: Static ( box StaticItem { ident, .. } )
1367+ | ForeignItemKind :: Fn ( box Fn { ident, .. } )
1368+ | ForeignItemKind :: TyAlias ( box TyAlias { ident, .. } ) => ident,
1369+ ForeignItemKind :: MacCall ( _) => {
1370+ self . visit_invoc_in_module ( foreign_item. id ) ;
1371+ return ;
1372+ }
1373+ } ;
13691374
1370- // `unwrap` is safe because `MacCall` has been excluded, and other foreign item kinds have
1371- // an ident.
1372- let ident = foreign_item. kind . ident ( ) . unwrap ( ) ;
13731375 self . build_reduced_graph_for_foreign_item ( foreign_item, ident) ;
13741376 visit:: walk_item ( self , foreign_item) ;
13751377 }
@@ -1384,26 +1386,35 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
13841386 }
13851387
13861388 fn visit_assoc_item ( & mut self , item : & ' a AssocItem , ctxt : AssocCtxt ) {
1387- if let AssocItemKind :: MacCall ( _) = item. kind {
1388- match ctxt {
1389- AssocCtxt :: Trait => {
1390- self . visit_invoc_in_module ( item. id ) ;
1391- }
1392- AssocCtxt :: Impl { .. } => {
1393- let invoc_id = item. id . placeholder_to_expn_id ( ) ;
1394- if !self . r . glob_delegation_invoc_ids . contains ( & invoc_id) {
1395- self . r
1396- . impl_unexpanded_invocations
1397- . entry ( self . r . invocation_parent ( invoc_id) )
1398- . or_default ( )
1399- . insert ( invoc_id) ;
1389+ let ( ident, ns) = match item. kind {
1390+ AssocItemKind :: Const ( box ConstItem { ident, .. } )
1391+ | AssocItemKind :: Fn ( box Fn { ident, .. } )
1392+ | AssocItemKind :: Delegation ( box Delegation { ident, .. } ) => ( ident, ValueNS ) ,
1393+
1394+ AssocItemKind :: Type ( box TyAlias { ident, .. } ) => ( ident, TypeNS ) ,
1395+
1396+ AssocItemKind :: MacCall ( _) => {
1397+ match ctxt {
1398+ AssocCtxt :: Trait => {
1399+ self . visit_invoc_in_module ( item. id ) ;
1400+ }
1401+ AssocCtxt :: Impl { .. } => {
1402+ let invoc_id = item. id . placeholder_to_expn_id ( ) ;
1403+ if !self . r . glob_delegation_invoc_ids . contains ( & invoc_id) {
1404+ self . r
1405+ . impl_unexpanded_invocations
1406+ . entry ( self . r . invocation_parent ( invoc_id) )
1407+ . or_default ( )
1408+ . insert ( invoc_id) ;
1409+ }
1410+ self . visit_invoc ( item. id ) ;
14001411 }
1401- self . visit_invoc ( item. id ) ;
14021412 }
1413+ return ;
14031414 }
1404- return ;
1405- }
14061415
1416+ AssocItemKind :: DelegationMac ( ..) => bug ! ( ) ,
1417+ } ;
14071418 let vis = self . resolve_visibility ( & item. vis ) ;
14081419 let feed = self . r . feed ( item. id ) ;
14091420 let local_def_id = feed. key ( ) ;
@@ -1418,16 +1429,6 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
14181429 self . r . feed_visibility ( feed, vis) ;
14191430 }
14201431
1421- let ns = match item. kind {
1422- AssocItemKind :: Const ( ..) | AssocItemKind :: Delegation ( ..) | AssocItemKind :: Fn ( ..) => {
1423- ValueNS
1424- }
1425- AssocItemKind :: Type ( ..) => TypeNS ,
1426- AssocItemKind :: MacCall ( _) | AssocItemKind :: DelegationMac ( ..) => bug ! ( ) , // handled above
1427- } ;
1428- // `unwrap` is safe because `MacCall`/`DelegationMac` have been excluded, and other foreign
1429- // item kinds have an ident.
1430- let ident = item. kind . ident ( ) . unwrap ( ) ;
14311432 if ctxt == AssocCtxt :: Trait {
14321433 let parent = self . parent_scope . module ;
14331434 let expansion = self . parent_scope . expansion ;
0 commit comments