@@ -19,7 +19,7 @@ use std::hash::Hash;
1919use syntax:: ast;
2020use syntax_pos:: symbol:: { Symbol , sym} ;
2121use syntax_pos:: hygiene:: ExpnId ;
22- use syntax_pos:: { Span , DUMMY_SP } ;
22+ use syntax_pos:: Span ;
2323
2424/// The `DefPathTable` maps `DefIndex`es to `DefKey`s and vice versa.
2525/// Internally the `DefPathTable` holds a tree of `DefKey`s, where each `DefKey`
@@ -310,10 +310,6 @@ pub enum DefPathData {
310310 AnonConst ,
311311 /// An `impl Trait` type node.
312312 ImplTrait ,
313- /// Identifies a piece of crate metadata that is global to a whole crate
314- /// (as opposed to just one item). `GlobalMetaData` components are only
315- /// supposed to show up right below the crate root.
316- GlobalMetaData ( Symbol ) ,
317313}
318314
319315#[ derive( Copy , Clone , Hash , PartialEq , Eq , PartialOrd , Ord , Debug ,
@@ -444,9 +440,6 @@ impl Definitions {
444440 self . node_to_def_index . insert ( ast:: CRATE_NODE_ID , root_index) ;
445441 self . set_invocation_parent ( ExpnId :: root ( ) , root_index) ;
446442
447- // Allocate some other `DefIndex`es that always must exist.
448- GlobalMetaDataKind :: allocate_def_indices ( self ) ;
449-
450443 root_index
451444 }
452445
@@ -553,8 +546,7 @@ impl DefPathData {
553546 TypeNs ( name) |
554547 ValueNs ( name) |
555548 MacroNs ( name) |
556- LifetimeNs ( name) |
557- GlobalMetaData ( name) => Some ( name) ,
549+ LifetimeNs ( name) => Some ( name) ,
558550
559551 Impl |
560552 CrateRoot |
@@ -572,8 +564,7 @@ impl DefPathData {
572564 TypeNs ( name) |
573565 ValueNs ( name) |
574566 MacroNs ( name) |
575- LifetimeNs ( name) |
576- GlobalMetaData ( name) => {
567+ LifetimeNs ( name) => {
577568 name
578569 }
579570 // Note that this does not show up in user print-outs.
@@ -591,78 +582,3 @@ impl DefPathData {
591582 self . as_symbol ( ) . to_string ( )
592583 }
593584}
594-
595- // We define the `GlobalMetaDataKind` enum with this macro because we want to
596- // make sure that we exhaustively iterate over all variants when registering
597- // the corresponding `DefIndex`es in the `DefTable`.
598- macro_rules! define_global_metadata_kind {
599- ( pub enum GlobalMetaDataKind {
600- $( $variant: ident) ,*
601- } ) => (
602- pub enum GlobalMetaDataKind {
603- $( $variant) ,*
604- }
605-
606- impl GlobalMetaDataKind {
607- fn allocate_def_indices( definitions: & mut Definitions ) {
608- $( {
609- let instance = GlobalMetaDataKind :: $variant;
610- definitions. create_def_with_parent(
611- CRATE_DEF_INDEX ,
612- ast:: DUMMY_NODE_ID ,
613- DefPathData :: GlobalMetaData ( instance. name( ) ) ,
614- ExpnId :: root( ) ,
615- DUMMY_SP
616- ) ;
617-
618- // Make sure calling `def_index` does not crash.
619- instance. def_index( & definitions. table) ;
620- } ) *
621- }
622-
623- pub fn def_index( & self , def_path_table: & DefPathTable ) -> DefIndex {
624- let def_key = DefKey {
625- parent: Some ( CRATE_DEF_INDEX ) ,
626- disambiguated_data: DisambiguatedDefPathData {
627- data: DefPathData :: GlobalMetaData ( self . name( ) ) ,
628- disambiguator: 0 ,
629- }
630- } ;
631-
632- // These `DefKey`s are all right after the root,
633- // so a linear search is fine.
634- let index = def_path_table. index_to_key
635- . iter( )
636- . position( |k| * k == def_key)
637- . unwrap( ) ;
638-
639- DefIndex :: from( index)
640- }
641-
642- fn name( & self ) -> Symbol {
643-
644- let string = match * self {
645- $(
646- GlobalMetaDataKind :: $variant => {
647- concat!( "{{GlobalMetaData::" , stringify!( $variant) , "}}" )
648- }
649- ) *
650- } ;
651-
652- Symbol :: intern( string)
653- }
654- }
655- )
656- }
657-
658- define_global_metadata_kind ! ( pub enum GlobalMetaDataKind {
659- Krate ,
660- CrateDeps ,
661- DylibDependencyFormats ,
662- LangItems ,
663- LangItemsMissing ,
664- NativeLibraries ,
665- SourceMap ,
666- Impls ,
667- ExportedSymbols
668- } ) ;
0 commit comments