@@ -5,37 +5,29 @@ use crate::schema;
5
5
use rustc:: dep_graph:: DepNodeIndex ;
6
6
use rustc:: hir:: def_id:: { CrateNum , DefIndex } ;
7
7
use rustc:: hir:: map:: definitions:: DefPathTable ;
8
- use rustc:: middle:: cstore:: { DepKind , ExternCrate , MetadataLoader } ;
8
+ use rustc:: middle:: cstore:: { CrateSource , DepKind , ExternCrate , MetadataLoader } ;
9
9
use rustc:: mir:: interpret:: AllocDecodingState ;
10
10
use rustc_index:: vec:: IndexVec ;
11
11
use 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 } ;
14
13
use syntax:: ast;
15
14
use syntax:: ext:: base:: SyntaxExtension ;
16
15
use 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 ;
21
17
22
18
pub use crate :: cstore_impl:: { provide, provide_extern} ;
23
19
24
20
// A map from external crate numbers (as decoded from some crate file) to
25
21
// local crate numbers (as generated during this session). Each external
26
22
// crate may refer to types in other external crates, and each has their
27
23
// own crate numbers.
28
- pub type CrateNumMap = IndexVec < CrateNum , CrateNum > ;
24
+ crate type CrateNumMap = IndexVec < CrateNum , CrateNum > ;
29
25
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 ) ;
35
27
36
28
/// Holds information about a syntax_pos::SourceFile imported from another crate.
37
29
/// See `imported_source_files()` for more information.
38
- pub struct ImportedSourceFile {
30
+ crate struct ImportedSourceFile {
39
31
/// This SourceFile's byte-offset within the source_map of its original crate
40
32
pub original_start_pos : syntax_pos:: BytePos ,
41
33
/// The end of this SourceFile within the source_map of its original crate
@@ -48,56 +40,54 @@ pub struct CrateMetadata {
48
40
/// Information about the extern crate that caused this crate to
49
41
/// be loaded. If this is `None`, then the crate was injected
50
42
/// (e.g., by the allocator)
51
- pub extern_crate : Lock < Option < ExternCrate > > ,
43
+ crate extern_crate : Lock < Option < ExternCrate > > ,
52
44
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 > > ,
58
50
59
51
/// Used for decoding interpret::AllocIds in a cached & thread-safe manner.
60
- pub alloc_decoding_state : AllocDecodingState ,
52
+ crate alloc_decoding_state : AllocDecodingState ,
61
53
62
54
// NOTE(eddyb) we pass `'static` to a `'tcx` parameter because this
63
55
// lifetime is only used behind `Lazy`, and therefore acts like an
64
56
// universal (`for<'tcx>`), that is paired up with whichever `TyCtxt`
65
57
// is being used to decode those values.
66
- pub root : schema:: CrateRoot < ' static > ,
58
+ crate root : schema:: CrateRoot < ' static > ,
67
59
68
60
/// For each definition in this crate, we encode a key. When the
69
61
/// crate is loaded, we read all the keys and put them in this
70
62
/// hashmap, which gives the reverse mapping. This allows us to
71
63
/// quickly retrace a `DefPath`, which is needed for incremental
72
64
/// compilation support.
73
- pub def_path_table : Lrc < DefPathTable > ,
65
+ crate def_path_table : Lrc < DefPathTable > ,
74
66
75
- pub trait_impls : FxHashMap < ( u32 , DefIndex ) , schema:: Lazy < [ DefIndex ] > > ,
67
+ crate trait_impls : FxHashMap < ( u32 , DefIndex ) , schema:: Lazy < [ DefIndex ] > > ,
76
68
77
- pub dep_kind : Lock < DepKind > ,
78
- pub source : CrateSource ,
69
+ crate dep_kind : Lock < DepKind > ,
70
+ crate source : CrateSource ,
79
71
80
72
/// Whether or not this crate should be consider a private dependency
81
73
/// for purposes of the 'exported_private_dependencies' lint
82
- pub private_dep : bool ,
83
-
84
- pub span : Span ,
74
+ crate private_dep : bool ,
85
75
86
- pub raw_proc_macros : Option < & ' static [ ProcMacro ] > ,
76
+ crate raw_proc_macros : Option < & ' static [ ProcMacro ] > ,
87
77
88
78
/// The `DepNodeIndex` of the `DepNode` representing this upstream crate.
89
79
/// It is initialized on the first access in `get_crate_dep_node_index()`.
90
80
/// Do not access the value directly, as it might not have been initialized
91
81
/// yet.
92
82
/// The field must always be initialized to `DepNodeIndex::INVALID`.
93
- pub ( super ) dep_node_index : AtomicCell < DepNodeIndex > ,
83
+ crate dep_node_index : AtomicCell < DepNodeIndex > ,
94
84
}
95
85
96
86
pub struct CStore {
97
87
metas : RwLock < IndexVec < CrateNum , Option < Lrc < CrateMetadata > > > > ,
98
88
/// Map from NodeId's of local extern crate statements to crate numbers
99
89
extern_mod_crate_map : Lock < NodeMap < CrateNum > > ,
100
- pub metadata_loader : Box < dyn MetadataLoader + Sync > ,
90
+ crate metadata_loader : Box < dyn MetadataLoader + Sync > ,
101
91
}
102
92
103
93
pub enum LoadedMacro {
@@ -118,25 +108,25 @@ impl CStore {
118
108
}
119
109
}
120
110
121
- pub ( super ) fn alloc_new_crate_num ( & self ) -> CrateNum {
111
+ crate fn alloc_new_crate_num ( & self ) -> CrateNum {
122
112
let mut metas = self . metas . borrow_mut ( ) ;
123
113
let cnum = CrateNum :: new ( metas. len ( ) ) ;
124
114
metas. push ( None ) ;
125
115
cnum
126
116
}
127
117
128
- pub ( super ) fn get_crate_data ( & self , cnum : CrateNum ) -> Lrc < CrateMetadata > {
118
+ crate fn get_crate_data ( & self , cnum : CrateNum ) -> Lrc < CrateMetadata > {
129
119
self . metas . borrow ( ) [ cnum] . clone ( )
130
120
. unwrap_or_else ( || panic ! ( "Failed to get crate data for {:?}" , cnum) )
131
121
}
132
122
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 > ) {
134
124
let mut metas = self . metas . borrow_mut ( ) ;
135
125
assert ! ( metas[ cnum] . is_none( ) , "Overwriting crate metadata entry" ) ;
136
126
metas[ cnum] = Some ( data) ;
137
127
}
138
128
139
- pub ( super ) fn iter_crate_data < I > ( & self , mut i : I )
129
+ crate fn iter_crate_data < I > ( & self , mut i : I )
140
130
where I : FnMut ( CrateNum , & Lrc < CrateMetadata > )
141
131
{
142
132
for ( k, v) in self . metas . borrow ( ) . iter_enumerated ( ) {
@@ -146,16 +136,14 @@ impl CStore {
146
136
}
147
137
}
148
138
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 > {
150
140
let mut ordering = Vec :: new ( ) ;
151
141
self . push_dependencies_in_postorder ( & mut ordering, krate) ;
152
142
ordering. reverse ( ) ;
153
143
ordering
154
144
}
155
145
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 ) {
159
147
if ordering. contains ( & krate) {
160
148
return ;
161
149
}
@@ -170,7 +158,7 @@ impl CStore {
170
158
ordering. push ( krate) ;
171
159
}
172
160
173
- pub ( super ) fn do_postorder_cnums_untracked ( & self ) -> Vec < CrateNum > {
161
+ crate fn do_postorder_cnums_untracked ( & self ) -> Vec < CrateNum > {
174
162
let mut ordering = Vec :: new ( ) ;
175
163
for ( num, v) in self . metas . borrow ( ) . iter_enumerated ( ) {
176
164
if let & Some ( _) = v {
@@ -180,11 +168,11 @@ impl CStore {
180
168
return ordering
181
169
}
182
170
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 ) {
184
172
self . extern_mod_crate_map . borrow_mut ( ) . insert ( emod_id, cnum) ;
185
173
}
186
174
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 > {
188
176
self . extern_mod_crate_map . borrow ( ) . get ( & emod_id) . cloned ( )
189
177
}
190
178
}
0 commit comments