@@ -5,37 +5,29 @@ use crate::schema;
55use rustc:: dep_graph:: DepNodeIndex ;
66use rustc:: hir:: def_id:: { CrateNum , DefIndex } ;
77use rustc:: hir:: map:: definitions:: DefPathTable ;
8- use rustc:: middle:: cstore:: { DepKind , ExternCrate , MetadataLoader } ;
8+ use rustc:: middle:: cstore:: { CrateSource , DepKind , ExternCrate , MetadataLoader } ;
99use rustc:: mir:: interpret:: AllocDecodingState ;
1010use rustc_index:: vec:: IndexVec ;
1111use rustc:: util:: nodemap:: { FxHashMap , NodeMap } ;
12-
13- use rustc_data_structures:: sync:: { Lrc , RwLock , Lock , AtomicCell } ;
12+ use rustc_data_structures:: sync:: { Lrc , RwLock , Lock , MetadataRef , AtomicCell } ;
1413use syntax:: ast;
1514use syntax:: ext:: base:: SyntaxExtension ;
1615use syntax_pos;
17-
18- pub use rustc:: middle:: cstore:: { NativeLibrary , NativeLibraryKind , LinkagePreference } ;
19- pub use rustc:: middle:: cstore:: NativeLibraryKind :: * ;
20- pub use rustc:: middle:: cstore:: { CrateSource , LibSource , ForeignModule } ;
16+ use proc_macro:: bridge:: client:: ProcMacro ;
2117
2218pub use crate :: cstore_impl:: { provide, provide_extern} ;
2319
2420// A map from external crate numbers (as decoded from some crate file) to
2521// local crate numbers (as generated during this session). Each external
2622// crate may refer to types in other external crates, and each has their
2723// own crate numbers.
28- pub type CrateNumMap = IndexVec < CrateNum , CrateNum > ;
24+ crate type CrateNumMap = IndexVec < CrateNum , CrateNum > ;
2925
30- pub use rustc_data_structures:: sync:: MetadataRef ;
31- use syntax_pos:: Span ;
32- use proc_macro:: bridge:: client:: ProcMacro ;
33-
34- pub struct MetadataBlob ( pub MetadataRef ) ;
26+ crate struct MetadataBlob ( pub MetadataRef ) ;
3527
3628/// Holds information about a syntax_pos::SourceFile imported from another crate.
3729/// See `imported_source_files()` for more information.
38- pub struct ImportedSourceFile {
30+ crate struct ImportedSourceFile {
3931 /// This SourceFile's byte-offset within the source_map of its original crate
4032 pub original_start_pos : syntax_pos:: BytePos ,
4133 /// The end of this SourceFile within the source_map of its original crate
@@ -48,56 +40,54 @@ pub struct CrateMetadata {
4840 /// Information about the extern crate that caused this crate to
4941 /// be loaded. If this is `None`, then the crate was injected
5042 /// (e.g., by the allocator)
51- pub extern_crate : Lock < Option < ExternCrate > > ,
43+ crate extern_crate : Lock < Option < ExternCrate > > ,
5244
53- pub blob : MetadataBlob ,
54- pub cnum_map : CrateNumMap ,
55- pub cnum : CrateNum ,
56- pub dependencies : Lock < Vec < CrateNum > > ,
57- pub source_map_import_info : RwLock < Vec < ImportedSourceFile > > ,
45+ crate blob : MetadataBlob ,
46+ crate cnum_map : CrateNumMap ,
47+ crate cnum : CrateNum ,
48+ crate dependencies : Lock < Vec < CrateNum > > ,
49+ crate source_map_import_info : RwLock < Vec < ImportedSourceFile > > ,
5850
5951 /// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
60- pub alloc_decoding_state : AllocDecodingState ,
52+ crate alloc_decoding_state : AllocDecodingState ,
6153
6254 // NOTE(eddyb) we pass `'static` to a `'tcx` parameter because this
6355 // lifetime is only used behind `Lazy`, and therefore acts like an
6456 // universal (`for<'tcx>`), that is paired up with whichever `TyCtxt`
6557 // is being used to decode those values.
66- pub root : schema:: CrateRoot < ' static > ,
58+ crate root : schema:: CrateRoot < ' static > ,
6759
6860 /// For each definition in this crate, we encode a key. When the
6961 /// crate is loaded, we read all the keys and put them in this
7062 /// hashmap, which gives the reverse mapping. This allows us to
7163 /// quickly retrace a `DefPath`, which is needed for incremental
7264 /// compilation support.
73- pub def_path_table : Lrc < DefPathTable > ,
65+ crate def_path_table : Lrc < DefPathTable > ,
7466
75- pub trait_impls : FxHashMap < ( u32 , DefIndex ) , schema:: Lazy < [ DefIndex ] > > ,
67+ crate trait_impls : FxHashMap < ( u32 , DefIndex ) , schema:: Lazy < [ DefIndex ] > > ,
7668
77- pub dep_kind : Lock < DepKind > ,
78- pub source : CrateSource ,
69+ crate dep_kind : Lock < DepKind > ,
70+ crate source : CrateSource ,
7971
8072 /// Whether or not this crate should be consider a private dependency
8173 /// for purposes of the 'exported_private_dependencies' lint
82- pub private_dep : bool ,
83-
84- pub span : Span ,
74+ crate private_dep : bool ,
8575
86- pub raw_proc_macros : Option < & ' static [ ProcMacro ] > ,
76+ crate raw_proc_macros : Option < & ' static [ ProcMacro ] > ,
8777
8878 /// The `DepNodeIndex` of the `DepNode` representing this upstream crate.
8979 /// It is initialized on the first access in `get_crate_dep_node_index()`.
9080 /// Do not access the value directly, as it might not have been initialized
9181 /// yet.
9282 /// The field must always be initialized to `DepNodeIndex::INVALID`.
93- pub ( super ) dep_node_index : AtomicCell < DepNodeIndex > ,
83+ crate dep_node_index : AtomicCell < DepNodeIndex > ,
9484}
9585
9686pub struct CStore {
9787 metas : RwLock < IndexVec < CrateNum , Option < Lrc < CrateMetadata > > > > ,
9888 /// Map from NodeId's of local extern crate statements to crate numbers
9989 extern_mod_crate_map : Lock < NodeMap < CrateNum > > ,
100- pub metadata_loader : Box < dyn MetadataLoader + Sync > ,
90+ crate metadata_loader : Box < dyn MetadataLoader + Sync > ,
10191}
10292
10393pub enum LoadedMacro {
@@ -118,25 +108,25 @@ impl CStore {
118108 }
119109 }
120110
121- pub ( super ) fn alloc_new_crate_num ( & self ) -> CrateNum {
111+ crate fn alloc_new_crate_num ( & self ) -> CrateNum {
122112 let mut metas = self . metas . borrow_mut ( ) ;
123113 let cnum = CrateNum :: new ( metas. len ( ) ) ;
124114 metas. push ( None ) ;
125115 cnum
126116 }
127117
128- pub ( super ) fn get_crate_data ( & self , cnum : CrateNum ) -> Lrc < CrateMetadata > {
118+ crate fn get_crate_data ( & self , cnum : CrateNum ) -> Lrc < CrateMetadata > {
129119 self . metas . borrow ( ) [ cnum] . clone ( )
130120 . unwrap_or_else ( || panic ! ( "Failed to get crate data for {:?}" , cnum) )
131121 }
132122
133- pub ( super ) fn set_crate_data ( & self , cnum : CrateNum , data : Lrc < CrateMetadata > ) {
123+ crate fn set_crate_data ( & self , cnum : CrateNum , data : Lrc < CrateMetadata > ) {
134124 let mut metas = self . metas . borrow_mut ( ) ;
135125 assert ! ( metas[ cnum] . is_none( ) , "Overwriting crate metadata entry" ) ;
136126 metas[ cnum] = Some ( data) ;
137127 }
138128
139- pub ( super ) fn iter_crate_data < I > ( & self , mut i : I )
129+ crate fn iter_crate_data < I > ( & self , mut i : I )
140130 where I : FnMut ( CrateNum , & Lrc < CrateMetadata > )
141131 {
142132 for ( k, v) in self . metas . borrow ( ) . iter_enumerated ( ) {
@@ -146,16 +136,14 @@ impl CStore {
146136 }
147137 }
148138
149- pub ( super ) fn crate_dependencies_in_rpo ( & self , krate : CrateNum ) -> Vec < CrateNum > {
139+ crate fn crate_dependencies_in_rpo ( & self , krate : CrateNum ) -> Vec < CrateNum > {
150140 let mut ordering = Vec :: new ( ) ;
151141 self . push_dependencies_in_postorder ( & mut ordering, krate) ;
152142 ordering. reverse ( ) ;
153143 ordering
154144 }
155145
156- pub ( super ) fn push_dependencies_in_postorder ( & self ,
157- ordering : & mut Vec < CrateNum > ,
158- krate : CrateNum ) {
146+ crate fn push_dependencies_in_postorder ( & self , ordering : & mut Vec < CrateNum > , krate : CrateNum ) {
159147 if ordering. contains ( & krate) {
160148 return ;
161149 }
@@ -170,7 +158,7 @@ impl CStore {
170158 ordering. push ( krate) ;
171159 }
172160
173- pub ( super ) fn do_postorder_cnums_untracked ( & self ) -> Vec < CrateNum > {
161+ crate fn do_postorder_cnums_untracked ( & self ) -> Vec < CrateNum > {
174162 let mut ordering = Vec :: new ( ) ;
175163 for ( num, v) in self . metas . borrow ( ) . iter_enumerated ( ) {
176164 if let & Some ( _) = v {
@@ -180,11 +168,11 @@ impl CStore {
180168 return ordering
181169 }
182170
183- pub ( super ) fn add_extern_mod_stmt_cnum ( & self , emod_id : ast:: NodeId , cnum : CrateNum ) {
171+ crate fn add_extern_mod_stmt_cnum ( & self , emod_id : ast:: NodeId , cnum : CrateNum ) {
184172 self . extern_mod_crate_map . borrow_mut ( ) . insert ( emod_id, cnum) ;
185173 }
186174
187- pub ( super ) fn do_extern_mod_stmt_cnum ( & self , emod_id : ast:: NodeId ) -> Option < CrateNum > {
175+ crate fn do_extern_mod_stmt_cnum ( & self , emod_id : ast:: NodeId ) -> Option < CrateNum > {
188176 self . extern_mod_crate_map . borrow ( ) . get ( & emod_id) . cloned ( )
189177 }
190178}
0 commit comments