@@ -10,8 +10,8 @@ use std::sync::Arc;
10
10
11
11
use rustc_ast:: visit:: { self , AssocCtxt , Visitor , WalkItemKind } ;
12
12
use 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 ,
15
15
} ;
16
16
use rustc_attr_parsing as attr;
17
17
use rustc_expand:: base:: ResolverExpand ;
@@ -764,8 +764,8 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
764
764
ItemKind :: ExternCrate ( orig_name, ident) => {
765
765
self . build_reduced_graph_for_extern_crate (
766
766
orig_name,
767
- ident,
768
767
item,
768
+ ident,
769
769
local_def_id,
770
770
vis,
771
771
parent,
@@ -797,7 +797,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
797
797
| ItemKind :: Static ( box StaticItem { ident, .. } ) => {
798
798
self . r . define ( parent, ident, ValueNS , ( res, vis, sp, expansion) ) ;
799
799
}
800
- ItemKind :: Fn ( box ast :: Fn { ident, .. } ) => {
800
+ ItemKind :: Fn ( box Fn { ident, .. } ) => {
801
801
self . r . define ( parent, ident, ValueNS , ( res, vis, sp, expansion) ) ;
802
802
803
803
// Functions introducing procedural macros reserve a slot
@@ -806,7 +806,7 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
806
806
}
807
807
808
808
// 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, ..) => {
810
810
self . r . define ( parent, ident, TypeNS , ( res, vis, sp, expansion) ) ;
811
811
}
812
812
@@ -900,8 +900,8 @@ impl<'a, 'ra, 'tcx> BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
900
900
fn build_reduced_graph_for_extern_crate (
901
901
& mut self ,
902
902
orig_name : Option < Symbol > ,
903
- ident : Ident ,
904
903
item : & Item ,
904
+ ident : Ident ,
905
905
local_def_id : LocalDefId ,
906
906
vis : ty:: Visibility ,
907
907
parent : Module < ' ra > ,
@@ -1362,14 +1362,16 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
1362
1362
}
1363
1363
1364
1364
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
+ } ;
1369
1374
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 ( ) ;
1373
1375
self . build_reduced_graph_for_foreign_item ( foreign_item, ident) ;
1374
1376
visit:: walk_item ( self , foreign_item) ;
1375
1377
}
@@ -1384,26 +1386,35 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
1384
1386
}
1385
1387
1386
1388
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 ) ;
1400
1411
}
1401
- self . visit_invoc ( item. id ) ;
1402
1412
}
1413
+ return ;
1403
1414
}
1404
- return ;
1405
- }
1406
1415
1416
+ AssocItemKind :: DelegationMac ( ..) => bug ! ( ) ,
1417
+ } ;
1407
1418
let vis = self . resolve_visibility ( & item. vis ) ;
1408
1419
let feed = self . r . feed ( item. id ) ;
1409
1420
let local_def_id = feed. key ( ) ;
@@ -1418,16 +1429,6 @@ impl<'a, 'ra, 'tcx> Visitor<'a> for BuildReducedGraphVisitor<'a, 'ra, 'tcx> {
1418
1429
self . r . feed_visibility ( feed, vis) ;
1419
1430
}
1420
1431
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 ( ) ;
1431
1432
if ctxt == AssocCtxt :: Trait {
1432
1433
let parent = self . parent_scope . module ;
1433
1434
let expansion = self . parent_scope . expansion ;
0 commit comments