@@ -54,7 +54,7 @@ pub struct ImportedFileMap {
5454 /// The end of this FileMap within the codemap of its original crate
5555 pub original_end_pos : syntax_pos:: BytePos ,
5656 /// 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 > ,
5858}
5959
6060pub struct CrateMetadata {
@@ -141,21 +141,23 @@ impl CStore {
141141 self . metas . borrow_mut ( ) . insert ( cnum, data) ;
142142 }
143143
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 > )
146146 {
147147 for ( & k, v) in self . metas . borrow ( ) . iter ( ) {
148148 i ( k, v) ;
149149 }
150150 }
151151
152152 /// 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 > )
155155 {
156156 for ( & k, v) in self . metas . borrow ( ) . iter ( ) {
157157 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+ } ) ;
159161 i ( k, & v, origin) ;
160162 }
161163 }
@@ -167,10 +169,12 @@ impl CStore {
167169 }
168170 }
169171
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 ( )
174178 }
175179
176180 pub fn reset ( & self ) {
@@ -182,19 +186,17 @@ impl CStore {
182186 self . statically_included_foreign_items . borrow_mut ( ) . clear ( ) ;
183187 }
184188
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 > {
187190 let mut ordering = Vec :: new ( ) ;
188191 self . push_dependencies_in_postorder ( & mut ordering, krate) ;
189192 ordering. reverse ( ) ;
190193 ordering
191194 }
192195
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+ }
198200
199201 let data = self . get_crate_data ( krate) ;
200202 for & dep in data. cnum_map . borrow ( ) . iter ( ) {
@@ -215,20 +217,25 @@ impl CStore {
215217 // In order to get this left-to-right dependency ordering, we perform a
216218 // topological sort of all crates putting the leaves at the right-most
217219 // positions.
218- pub fn do_get_used_crates ( & self , prefer : LinkagePreference )
220+ pub fn do_get_used_crates ( & self ,
221+ prefer : LinkagePreference )
219222 -> Vec < ( CrateNum , Option < PathBuf > ) > {
220223 let mut ordering = Vec :: new ( ) ;
221224 for ( & num, _) in self . metas . borrow ( ) . iter ( ) {
222225 self . push_dependencies_in_postorder ( & mut ordering, num) ;
223226 }
224227 info ! ( "topological ordering: {:?}" , ordering) ;
225228 ordering. reverse ( ) ;
226- let mut libs = self . used_crate_sources . borrow ( )
229+ let mut libs = self . used_crate_sources
230+ . borrow ( )
227231 . 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+ } )
232239 . collect :: < Vec < _ > > ( ) ;
233240 libs. sort_by ( |& ( a, _) , & ( b, _) | {
234241 let a = ordering. iter ( ) . position ( |x| * x == a) ;
@@ -243,9 +250,7 @@ impl CStore {
243250 self . used_libraries . borrow_mut ( ) . push ( ( lib, kind) ) ;
244251 }
245252
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 ) > > {
249254 & self . used_libraries
250255 }
251256
@@ -255,13 +260,11 @@ impl CStore {
255260 }
256261 }
257262
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 > > {
259264 & self . used_link_args
260265 }
261266
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 ) {
265268 self . extern_mod_crate_map . borrow_mut ( ) . insert ( emod_id, cnum) ;
266269 }
267270
@@ -273,8 +276,7 @@ impl CStore {
273276 self . statically_included_foreign_items . borrow ( ) . contains ( & id)
274277 }
275278
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 > {
278280 self . extern_mod_crate_map . borrow ( ) . get ( & emod_id) . cloned ( )
279281 }
280282
@@ -288,14 +290,20 @@ impl CStore {
288290}
289291
290292impl 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+ }
294302
295303 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" )
299307 }
300308
301309 pub fn is_allocator ( & self ) -> bool {
0 commit comments