@@ -54,7 +54,7 @@ pub struct ImportedFileMap {
54
54
/// The end of this FileMap within the codemap of its original crate
55
55
pub original_end_pos : syntax_pos:: BytePos ,
56
56
/// The imported FileMap's representation within the local codemap
57
- pub translated_filemap : Rc < syntax_pos:: FileMap >
57
+ pub translated_filemap : Rc < syntax_pos:: FileMap > ,
58
58
}
59
59
60
60
pub struct CrateMetadata {
@@ -141,21 +141,23 @@ impl CStore {
141
141
self . metas . borrow_mut ( ) . insert ( cnum, data) ;
142
142
}
143
143
144
- pub fn iter_crate_data < I > ( & self , mut i : I ) where
145
- I : FnMut ( CrateNum , & Rc < CrateMetadata > ) ,
144
+ pub fn iter_crate_data < I > ( & self , mut i : I )
145
+ where I : FnMut ( CrateNum , & Rc < CrateMetadata > )
146
146
{
147
147
for ( & k, v) in self . metas . borrow ( ) . iter ( ) {
148
148
i ( k, v) ;
149
149
}
150
150
}
151
151
152
152
/// Like `iter_crate_data`, but passes source paths (if available) as well.
153
- pub fn iter_crate_data_origins < I > ( & self , mut i : I ) where
154
- I : FnMut ( CrateNum , & CrateMetadata , Option < CrateSource > ) ,
153
+ pub fn iter_crate_data_origins < I > ( & self , mut i : I )
154
+ where I : FnMut ( CrateNum , & CrateMetadata , Option < CrateSource > )
155
155
{
156
156
for ( & k, v) in self . metas . borrow ( ) . iter ( ) {
157
157
let origin = self . opt_used_crate_source ( k) ;
158
- origin. as_ref ( ) . map ( |cs| { assert ! ( k == cs. cnum) ; } ) ;
158
+ origin. as_ref ( ) . map ( |cs| {
159
+ assert ! ( k == cs. cnum) ;
160
+ } ) ;
159
161
i ( k, & v, origin) ;
160
162
}
161
163
}
@@ -167,10 +169,12 @@ impl CStore {
167
169
}
168
170
}
169
171
170
- pub fn opt_used_crate_source ( & self , cnum : CrateNum )
171
- -> Option < CrateSource > {
172
- self . used_crate_sources . borrow_mut ( )
173
- . iter ( ) . find ( |source| source. cnum == cnum) . cloned ( )
172
+ pub fn opt_used_crate_source ( & self , cnum : CrateNum ) -> Option < CrateSource > {
173
+ self . used_crate_sources
174
+ . borrow_mut ( )
175
+ . iter ( )
176
+ . find ( |source| source. cnum == cnum)
177
+ . cloned ( )
174
178
}
175
179
176
180
pub fn reset ( & self ) {
@@ -182,19 +186,17 @@ impl CStore {
182
186
self . statically_included_foreign_items . borrow_mut ( ) . clear ( ) ;
183
187
}
184
188
185
- pub fn crate_dependencies_in_rpo ( & self , krate : CrateNum ) -> Vec < CrateNum >
186
- {
189
+ pub fn crate_dependencies_in_rpo ( & self , krate : CrateNum ) -> Vec < CrateNum > {
187
190
let mut ordering = Vec :: new ( ) ;
188
191
self . push_dependencies_in_postorder ( & mut ordering, krate) ;
189
192
ordering. reverse ( ) ;
190
193
ordering
191
194
}
192
195
193
- pub fn push_dependencies_in_postorder ( & self ,
194
- ordering : & mut Vec < CrateNum > ,
195
- krate : CrateNum )
196
- {
197
- if ordering. contains ( & krate) { return }
196
+ pub fn push_dependencies_in_postorder ( & self , ordering : & mut Vec < CrateNum > , krate : CrateNum ) {
197
+ if ordering. contains ( & krate) {
198
+ return ;
199
+ }
198
200
199
201
let data = self . get_crate_data ( krate) ;
200
202
for & dep in data. cnum_map . borrow ( ) . iter ( ) {
@@ -215,20 +217,25 @@ impl CStore {
215
217
// In order to get this left-to-right dependency ordering, we perform a
216
218
// topological sort of all crates putting the leaves at the right-most
217
219
// positions.
218
- pub fn do_get_used_crates ( & self , prefer : LinkagePreference )
220
+ pub fn do_get_used_crates ( & self ,
221
+ prefer : LinkagePreference )
219
222
-> Vec < ( CrateNum , Option < PathBuf > ) > {
220
223
let mut ordering = Vec :: new ( ) ;
221
224
for ( & num, _) in self . metas . borrow ( ) . iter ( ) {
222
225
self . push_dependencies_in_postorder ( & mut ordering, num) ;
223
226
}
224
227
info ! ( "topological ordering: {:?}" , ordering) ;
225
228
ordering. reverse ( ) ;
226
- let mut libs = self . used_crate_sources . borrow ( )
229
+ let mut libs = self . used_crate_sources
230
+ . borrow ( )
227
231
. iter ( )
228
- . map ( |src| ( src. cnum , match prefer {
229
- LinkagePreference :: RequireDynamic => src. dylib . clone ( ) . map ( |p| p. 0 ) ,
230
- LinkagePreference :: RequireStatic => src. rlib . clone ( ) . map ( |p| p. 0 ) ,
231
- } ) )
232
+ . map ( |src| {
233
+ ( src. cnum ,
234
+ match prefer {
235
+ LinkagePreference :: RequireDynamic => src. dylib . clone ( ) . map ( |p| p. 0 ) ,
236
+ LinkagePreference :: RequireStatic => src. rlib . clone ( ) . map ( |p| p. 0 ) ,
237
+ } )
238
+ } )
232
239
. collect :: < Vec < _ > > ( ) ;
233
240
libs. sort_by ( |& ( a, _) , & ( b, _) | {
234
241
let a = ordering. iter ( ) . position ( |x| * x == a) ;
@@ -243,9 +250,7 @@ impl CStore {
243
250
self . used_libraries . borrow_mut ( ) . push ( ( lib, kind) ) ;
244
251
}
245
252
246
- pub fn get_used_libraries < ' a > ( & ' a self )
247
- -> & ' a RefCell < Vec < ( String ,
248
- NativeLibraryKind ) > > {
253
+ pub fn get_used_libraries < ' a > ( & ' a self ) -> & ' a RefCell < Vec < ( String , NativeLibraryKind ) > > {
249
254
& self . used_libraries
250
255
}
251
256
@@ -255,13 +260,11 @@ impl CStore {
255
260
}
256
261
}
257
262
258
- pub fn get_used_link_args < ' a > ( & ' a self ) -> & ' a RefCell < Vec < String > > {
263
+ pub fn get_used_link_args < ' a > ( & ' a self ) -> & ' a RefCell < Vec < String > > {
259
264
& self . used_link_args
260
265
}
261
266
262
- pub fn add_extern_mod_stmt_cnum ( & self ,
263
- emod_id : ast:: NodeId ,
264
- cnum : CrateNum ) {
267
+ pub fn add_extern_mod_stmt_cnum ( & self , emod_id : ast:: NodeId , cnum : CrateNum ) {
265
268
self . extern_mod_crate_map . borrow_mut ( ) . insert ( emod_id, cnum) ;
266
269
}
267
270
@@ -273,8 +276,7 @@ impl CStore {
273
276
self . statically_included_foreign_items . borrow ( ) . contains ( & id)
274
277
}
275
278
276
- pub fn do_extern_mod_stmt_cnum ( & self , emod_id : ast:: NodeId ) -> Option < CrateNum >
277
- {
279
+ pub fn do_extern_mod_stmt_cnum ( & self , emod_id : ast:: NodeId ) -> Option < CrateNum > {
278
280
self . extern_mod_crate_map . borrow ( ) . get ( & emod_id) . cloned ( )
279
281
}
280
282
@@ -288,14 +290,20 @@ impl CStore {
288
290
}
289
291
290
292
impl CrateMetadata {
291
- pub fn name ( & self ) -> & str { & self . root . name }
292
- pub fn hash ( & self ) -> Svh { self . root . hash }
293
- pub fn disambiguator ( & self ) -> & str { & self . root . disambiguator }
293
+ pub fn name ( & self ) -> & str {
294
+ & self . root . name
295
+ }
296
+ pub fn hash ( & self ) -> Svh {
297
+ self . root . hash
298
+ }
299
+ pub fn disambiguator ( & self ) -> & str {
300
+ & self . root . disambiguator
301
+ }
294
302
295
303
pub fn is_staged_api ( & self ) -> bool {
296
- self . get_item_attrs ( CRATE_DEF_INDEX ) . iter ( ) . any ( |attr| {
297
- attr . name ( ) == "stable" || attr . name ( ) == "unstable"
298
- } )
304
+ self . get_item_attrs ( CRATE_DEF_INDEX )
305
+ . iter ( )
306
+ . any ( |attr| attr . name ( ) == "stable" || attr . name ( ) == "unstable" )
299
307
}
300
308
301
309
pub fn is_allocator ( & self ) -> bool {
0 commit comments