88// option. This file may not be copied, modified, or distributed
99// except according to those terms.
1010
11- use cstore;
11+ use cstore:: { self , LoadedMacro } ;
1212use encoder;
1313use link_args;
1414use native_libs;
@@ -17,8 +17,8 @@ use schema;
1717
1818use rustc:: ty:: query:: QueryConfig ;
1919use rustc:: middle:: cstore:: { CrateStore , DepKind ,
20- MetadataLoader , LinkMeta ,
21- LoadedMacro , EncodedMetadata , NativeLibraryKind } ;
20+ LinkMeta ,
21+ EncodedMetadata , NativeLibraryKind } ;
2222use rustc:: middle:: exported_symbols:: ExportedSymbol ;
2323use rustc:: middle:: stability:: DeprecationEntry ;
2424use rustc:: hir:: def;
@@ -411,102 +411,37 @@ pub fn provide<'tcx>(providers: &mut Providers<'tcx>) {
411411 } ;
412412}
413413
414- impl CrateStore for cstore:: CStore {
415- fn crate_data_as_rc_any ( & self , krate : CrateNum ) -> Lrc < dyn Any > {
416- self . get_crate_data ( krate)
417- }
418-
419- fn metadata_loader ( & self ) -> & dyn MetadataLoader {
420- & * self . metadata_loader
421- }
422-
423- fn item_generics_cloned_untracked ( & self , def : DefId , sess : & Session ) -> ty:: Generics {
424- self . get_crate_data ( def. krate ) . get_generics ( def. index , sess)
425- }
426-
427- fn associated_item_cloned_untracked ( & self , def : DefId ) -> ty:: AssociatedItem
428- {
429- self . get_crate_data ( def. krate ) . get_associated_item ( def. index )
430- }
431-
432- fn dep_kind_untracked ( & self , cnum : CrateNum ) -> DepKind
433- {
434- let data = self . get_crate_data ( cnum) ;
435- let r = * data. dep_kind . lock ( ) ;
436- r
437- }
438-
439- fn export_macros_untracked ( & self , cnum : CrateNum ) {
414+ impl cstore:: CStore {
415+ pub fn export_macros_untracked ( & self , cnum : CrateNum ) {
440416 let data = self . get_crate_data ( cnum) ;
441417 let mut dep_kind = data. dep_kind . lock ( ) ;
442418 if * dep_kind == DepKind :: UnexportedMacrosOnly {
443419 * dep_kind = DepKind :: MacrosOnly ;
444420 }
445421 }
446422
447- fn crate_name_untracked ( & self , cnum : CrateNum ) -> Symbol
448- {
449- self . get_crate_data ( cnum) . name
450- }
451-
452- fn crate_disambiguator_untracked ( & self , cnum : CrateNum ) -> CrateDisambiguator
453- {
454- self . get_crate_data ( cnum) . root . disambiguator
455- }
456-
457- fn crate_hash_untracked ( & self , cnum : CrateNum ) -> hir:: svh:: Svh
458- {
459- self . get_crate_data ( cnum) . root . hash
423+ pub fn dep_kind_untracked ( & self , cnum : CrateNum ) -> DepKind {
424+ let data = self . get_crate_data ( cnum) ;
425+ let r = * data. dep_kind . lock ( ) ;
426+ r
460427 }
461428
462- fn crate_edition_untracked ( & self , cnum : CrateNum ) -> Edition
463- {
429+ pub fn crate_edition_untracked ( & self , cnum : CrateNum ) -> Edition {
464430 self . get_crate_data ( cnum) . root . edition
465431 }
466432
467- /// Returns the `DefKey` for a given `DefId`. This indicates the
468- /// parent `DefId` as well as some idea of what kind of data the
469- /// `DefId` refers to.
470- fn def_key ( & self , def : DefId ) -> DefKey {
471- // Note: loading the def-key (or def-path) for a def-id is not
472- // a *read* of its metadata. This is because the def-id is
473- // really just an interned shorthand for a def-path, which is the
474- // canonical name for an item.
475- //
476- // self.dep_graph.read(DepNode::MetaData(def));
477- self . get_crate_data ( def. krate ) . def_key ( def. index )
478- }
479-
480- fn def_path ( & self , def : DefId ) -> DefPath {
481- // See `Note` above in `def_key()` for why this read is
482- // commented out:
483- //
484- // self.dep_graph.read(DepNode::MetaData(def));
485- self . get_crate_data ( def. krate ) . def_path ( def. index )
486- }
487-
488- fn def_path_hash ( & self , def : DefId ) -> DefPathHash {
489- self . get_crate_data ( def. krate ) . def_path_hash ( def. index )
490- }
491-
492- fn def_path_table ( & self , cnum : CrateNum ) -> Lrc < DefPathTable > {
493- self . get_crate_data ( cnum) . def_path_table . clone ( )
494- }
495-
496- fn struct_field_names_untracked ( & self , def : DefId ) -> Vec < ast:: Name >
497- {
433+ pub fn struct_field_names_untracked ( & self , def : DefId ) -> Vec < ast:: Name > {
498434 self . get_crate_data ( def. krate ) . get_struct_field_names ( def. index )
499435 }
500436
501- fn item_children_untracked ( & self , def_id : DefId , sess : & Session ) -> Vec < def:: Export >
502- {
437+ pub fn item_children_untracked ( & self , def_id : DefId , sess : & Session ) -> Vec < def:: Export > {
503438 let mut result = vec ! [ ] ;
504439 self . get_crate_data ( def_id. krate )
505440 . each_child_of_item ( def_id. index , |child| result. push ( child) , sess) ;
506441 result
507442 }
508443
509- fn load_macro_untracked ( & self , id : DefId , sess : & Session ) -> LoadedMacro {
444+ pub fn load_macro_untracked ( & self , id : DefId , sess : & Session ) -> LoadedMacro {
510445 let data = self . get_crate_data ( id. krate ) ;
511446 if let Some ( ref proc_macros) = data. proc_macros {
512447 return LoadedMacro :: ProcMacro ( proc_macros[ id. index . to_proc_macro_index ( ) ] . 1 . clone ( ) ) ;
@@ -555,6 +490,64 @@ impl CrateStore for cstore::CStore {
555490 } )
556491 }
557492
493+ pub fn associated_item_cloned_untracked ( & self , def : DefId ) -> ty:: AssociatedItem {
494+ self . get_crate_data ( def. krate ) . get_associated_item ( def. index )
495+ }
496+ }
497+
498+ impl CrateStore for cstore:: CStore {
499+ fn crate_data_as_rc_any ( & self , krate : CrateNum ) -> Lrc < dyn Any > {
500+ self . get_crate_data ( krate)
501+ }
502+
503+ fn item_generics_cloned_untracked ( & self , def : DefId , sess : & Session ) -> ty:: Generics {
504+ self . get_crate_data ( def. krate ) . get_generics ( def. index , sess)
505+ }
506+
507+ fn crate_name_untracked ( & self , cnum : CrateNum ) -> Symbol
508+ {
509+ self . get_crate_data ( cnum) . name
510+ }
511+
512+ fn crate_disambiguator_untracked ( & self , cnum : CrateNum ) -> CrateDisambiguator
513+ {
514+ self . get_crate_data ( cnum) . root . disambiguator
515+ }
516+
517+ fn crate_hash_untracked ( & self , cnum : CrateNum ) -> hir:: svh:: Svh
518+ {
519+ self . get_crate_data ( cnum) . root . hash
520+ }
521+
522+ /// Returns the `DefKey` for a given `DefId`. This indicates the
523+ /// parent `DefId` as well as some idea of what kind of data the
524+ /// `DefId` refers to.
525+ fn def_key ( & self , def : DefId ) -> DefKey {
526+ // Note: loading the def-key (or def-path) for a def-id is not
527+ // a *read* of its metadata. This is because the def-id is
528+ // really just an interned shorthand for a def-path, which is the
529+ // canonical name for an item.
530+ //
531+ // self.dep_graph.read(DepNode::MetaData(def));
532+ self . get_crate_data ( def. krate ) . def_key ( def. index )
533+ }
534+
535+ fn def_path ( & self , def : DefId ) -> DefPath {
536+ // See `Note` above in `def_key()` for why this read is
537+ // commented out:
538+ //
539+ // self.dep_graph.read(DepNode::MetaData(def));
540+ self . get_crate_data ( def. krate ) . def_path ( def. index )
541+ }
542+
543+ fn def_path_hash ( & self , def : DefId ) -> DefPathHash {
544+ self . get_crate_data ( def. krate ) . def_path_hash ( def. index )
545+ }
546+
547+ fn def_path_table ( & self , cnum : CrateNum ) -> Lrc < DefPathTable > {
548+ self . get_crate_data ( cnum) . def_path_table . clone ( )
549+ }
550+
558551 fn crates_untracked ( & self ) -> Vec < CrateNum >
559552 {
560553 let mut result = vec ! [ ] ;
0 commit comments