@@ -21,7 +21,7 @@ use rustc_hir::def_id::{CRATE_DEF_ID, DefId, LocalDefId};
2121use rustc_index:: bit_set:: DenseBitSet ;
2222use rustc_metadata:: creader:: LoadedMacro ;
2323use rustc_middle:: metadata:: { ModChild , Reexport } ;
24- use rustc_middle:: ty:: { Feed , Visibility } ;
24+ use rustc_middle:: ty:: { TyCtxtFeed , Visibility } ;
2525use rustc_middle:: { bug, span_bug} ;
2626use rustc_span:: hygiene:: { ExpnId , LocalExpnId , MacroKind } ;
2727use rustc_span:: { Ident , Span , Symbol , kw, sym} ;
@@ -563,6 +563,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
563563 item : & Item ,
564564 vis : Visibility ,
565565 root_span : Span ,
566+ feed : TyCtxtFeed < ' tcx , LocalDefId > ,
566567 ) {
567568 debug ! (
568569 "build_reduced_graph_for_use_tree(parent_prefix={:?}, use_tree={:?}, nested={})" ,
@@ -572,7 +573,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
572573 // Top level use tree reuses the item's id and list stems reuse their parent
573574 // use tree's ids, so in both cases their visibilities are already filled.
574575 if nested && !list_stem {
575- self . r . feed_visibility ( self . r . feed ( id ) , vis) ;
576+ self . r . feed_visibility ( feed, vis) ;
576577 }
577578
578579 let mut prefix_iter = parent_prefix
@@ -735,11 +736,11 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
735736 }
736737 ast:: UseTreeKind :: Nested { ref items, .. } => {
737738 for & ( ref tree, id) in items {
738- self . create_def ( id, None , DefKind :: Use , use_tree. span ( ) ) ;
739+ let feed = self . create_def ( id, None , DefKind :: Use , use_tree. span ( ) ) ;
739740 self . build_reduced_graph_for_use_tree (
740741 // This particular use tree
741742 tree, id, & prefix, true , false , // The whole `use` item
742- item, vis, root_span,
743+ item, vis, root_span, feed ,
743744 ) ;
744745 }
745746
@@ -768,6 +769,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
768769 self . parent_scope . module . nearest_parent_mod ( ) . expect_local ( ) ,
769770 ) ,
770771 root_span,
772+ feed,
771773 ) ;
772774 }
773775 }
@@ -778,7 +780,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
778780 & mut self ,
779781 fields : & [ ast:: FieldDef ] ,
780782 ident : Ident ,
781- feed : Feed < ' tcx , LocalDefId > ,
783+ feed : TyCtxtFeed < ' tcx , LocalDefId > ,
782784 adt_res : Res ,
783785 adt_vis : Visibility ,
784786 adt_span : Span ,
@@ -798,13 +800,12 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
798800 }
799801
800802 /// Constructs the reduced graph for one item.
801- fn build_reduced_graph_for_item ( & mut self , item : & ' a Item ) {
803+ fn build_reduced_graph_for_item ( & mut self , item : & ' a Item , feed : TyCtxtFeed < ' tcx , LocalDefId > ) {
802804 let parent_scope = & self . parent_scope ;
803805 let parent = parent_scope. module . expect_local ( ) ;
804806 let expansion = parent_scope. expansion ;
805807 let sp = item. span ;
806808 let vis = self . resolve_visibility ( & item. vis ) ;
807- let feed = self . r . feed ( item. id ) ;
808809 let local_def_id = feed. key ( ) ;
809810 let def_id = local_def_id. to_def_id ( ) ;
810811 let def_kind = self . r . tcx . def_kind ( def_id) ;
@@ -825,6 +826,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
825826 item,
826827 vis,
827828 use_tree. span ( ) ,
829+ feed,
828830 ) ;
829831 }
830832
@@ -867,7 +869,7 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
867869
868870 // Functions introducing procedural macros reserve a slot
869871 // in the macro namespace as well (see #52225).
870- self . define_macro ( item) ;
872+ self . define_macro ( item, feed ) ;
871873 }
872874
873875 // These items live in the type namespace.
@@ -928,14 +930,13 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
928930 field_visibilities. push ( field_vis. to_def_id ( ) ) ;
929931 }
930932 // If this is a unit or tuple-like struct, register the constructor.
931- self . create_def (
933+ let feed = self . create_def (
932934 ctor_node_id,
933935 None ,
934936 DefKind :: Ctor ( CtorOf :: Struct , ctor_kind) ,
935937 item. span ,
936938 ) ;
937939
938- let feed = self . r . feed ( ctor_node_id) ;
939940 let ctor_def_id = feed. key ( ) ;
940941 let ctor_res = self . res ( ctor_def_id) ;
941942 self . r . define_local ( parent, ident, ValueNS , ctor_res, ctor_vis, sp, expansion) ;
@@ -1070,8 +1071,8 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
10701071 & mut self ,
10711072 item : & ForeignItem ,
10721073 ident : Ident ,
1074+ feed : TyCtxtFeed < ' tcx , LocalDefId > ,
10731075 ) {
1074- let feed = self . r . feed ( item. id ) ;
10751076 let local_def_id = feed. key ( ) ;
10761077 let def_id = local_def_id. to_def_id ( ) ;
10771078 let ns = match item. kind {
@@ -1267,10 +1268,13 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
12671268 }
12681269 }
12691270
1270- fn define_macro ( & mut self , item : & ast:: Item ) -> MacroRulesScopeRef < ' ra > {
1271+ fn define_macro (
1272+ & mut self ,
1273+ item : & ast:: Item ,
1274+ feed : TyCtxtFeed < ' tcx , LocalDefId > ,
1275+ ) -> MacroRulesScopeRef < ' ra > {
12711276 let parent_scope = self . parent_scope ;
12721277 let expansion = parent_scope. expansion ;
1273- let feed = self . r . feed ( item. id ) ;
12741278 let def_id = feed. key ( ) ;
12751279 let ( res, orig_ident, span, macro_rules) = match & item. kind {
12761280 ItemKind :: MacroDef ( ident, def) => {
@@ -1369,17 +1373,17 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
13691373}
13701374
13711375impl < ' a , ' ra , ' tcx > DefCollector < ' a , ' ra , ' tcx > {
1372- pub ( crate ) fn brg_visit_item ( & mut self , item : & ' a Item ) {
1376+ pub ( crate ) fn brg_visit_item ( & mut self , item : & ' a Item , feed : TyCtxtFeed < ' tcx , LocalDefId > ) {
13731377 let orig_module_scope = self . parent_scope . module ;
13741378 self . parent_scope . macro_rules = match item. kind {
13751379 ItemKind :: MacroDef ( ..) => {
1376- let macro_rules_scope = self . define_macro ( item) ;
1380+ let macro_rules_scope = self . define_macro ( item, feed ) ;
13771381 visit:: walk_item ( self , item) ;
13781382 macro_rules_scope
13791383 }
13801384 _ => {
13811385 let orig_macro_rules_scope = self . parent_scope . macro_rules ;
1382- self . build_reduced_graph_for_item ( item) ;
1386+ self . build_reduced_graph_for_item ( item, feed ) ;
13831387 match item. kind {
13841388 ItemKind :: Mod ( ..) => {
13851389 // Visit attributes after items for backward compatibility.
@@ -1422,9 +1426,9 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
14221426 ctxt : AssocCtxt ,
14231427 ident : Ident ,
14241428 ns : Namespace ,
1429+ feed : TyCtxtFeed < ' tcx , LocalDefId > ,
14251430 ) {
14261431 let vis = self . resolve_visibility ( & item. vis ) ;
1427- let feed = self . r . feed ( item. id ) ;
14281432 let local_def_id = feed. key ( ) ;
14291433 let def_id = local_def_id. to_def_id ( ) ;
14301434
@@ -1476,21 +1480,28 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
14761480 }
14771481 }
14781482
1479- pub ( crate ) fn brg_visit_field_def ( & mut self , sf : & ' a ast:: FieldDef ) {
1483+ pub ( crate ) fn brg_visit_field_def (
1484+ & mut self ,
1485+ sf : & ' a ast:: FieldDef ,
1486+ feed : TyCtxtFeed < ' tcx , LocalDefId > ,
1487+ ) {
14801488 let vis = self . resolve_visibility ( & sf. vis ) ;
1481- self . r . feed_visibility ( self . r . feed ( sf . id ) , vis) ;
1489+ self . r . feed_visibility ( feed, vis) ;
14821490 visit:: walk_field_def ( self , sf) ;
14831491 }
14841492
14851493 // Constructs the reduced graph for one variant. Variants exist in the
14861494 // type and value namespaces.
1487- pub ( crate ) fn brg_visit_variant ( & mut self , variant : & ' a ast:: Variant ) {
1495+ pub ( crate ) fn brg_visit_variant (
1496+ & mut self ,
1497+ variant : & ' a ast:: Variant ,
1498+ feed : TyCtxtFeed < ' tcx , LocalDefId > ,
1499+ ) {
14881500 let parent = self . parent_scope . module . expect_local ( ) ;
14891501 let expn_id = self . parent_scope . expansion ;
14901502 let ident = variant. ident ;
14911503
14921504 // Define a name in the type namespace.
1493- let feed = self . r . feed ( variant. id ) ;
14941505 let def_id = feed. key ( ) ;
14951506 let vis = self . resolve_visibility ( & variant. vis ) ;
14961507 self . r . define_local ( parent, ident, TypeNS , self . res ( def_id) , vis, variant. span , expn_id) ;
@@ -1506,13 +1517,12 @@ impl<'a, 'ra, 'tcx> DefCollector<'a, 'ra, 'tcx> {
15061517
15071518 // Define a constructor name in the value namespace.
15081519 if let Some ( ( ctor_kind, ctor_node_id) ) = CtorKind :: from_ast ( & variant. data ) {
1509- self . create_def (
1520+ let feed = self . create_def (
15101521 ctor_node_id,
15111522 None ,
15121523 DefKind :: Ctor ( CtorOf :: Variant , ctor_kind) ,
15131524 variant. span ,
15141525 ) ;
1515- let feed = self . r . feed ( ctor_node_id) ;
15161526 let ctor_def_id = feed. key ( ) ;
15171527 let ctor_res = self . res ( ctor_def_id) ;
15181528 self . r . define_local ( parent, ident, ValueNS , ctor_res, ctor_vis, variant. span , expn_id) ;
0 commit comments