@@ -16,7 +16,8 @@ use itertools::Itertools;
1616use serde:: { Deserialize , Serialize } ;
1717use std:: {
1818 collections:: { BTreeMap , BTreeSet , HashSet } ,
19- io:: Read , task:: Poll ,
19+ io:: Read ,
20+ task:: Poll ,
2021} ;
2122
2223const PLAYGROUND_TARGET_PLATFORM : & str = "x86_64-unknown-linux-gnu" ;
@@ -92,10 +93,13 @@ fn simple_get(url: &str) -> reqwest::Result<reqwest::blocking::Response> {
9293impl TopCrates {
9394 /// List top 100 crates by number of downloads on crates.io.
9495 fn download ( ) -> TopCrates {
95- let resp =
96- simple_get ( "https://crates.io/api/v1/crates?page=1&per_page=100&sort=downloads" )
97- . expect ( "Could not fetch top crates" ) ;
98- assert ! ( resp. status( ) . is_success( ) , "Could not download top crates; HTTP status was {}" , resp. status( ) ) ;
96+ let resp = simple_get ( "https://crates.io/api/v1/crates?page=1&per_page=100&sort=downloads" )
97+ . expect ( "Could not fetch top crates" ) ;
98+ assert ! (
99+ resp. status( ) . is_success( ) ,
100+ "Could not download top crates; HTTP status was {}" ,
101+ resp. status( ) ,
102+ ) ;
99103
100104 serde_json:: from_reader ( resp) . expect ( "Invalid JSON" )
101105 }
@@ -105,7 +109,11 @@ impl TopCrates {
105109 "https://raw.githubusercontent.com/rust-lang-nursery/rust-cookbook/master/Cargo.toml" ,
106110 )
107111 . expect ( "Could not fetch cookbook manifest" ) ;
108- assert ! ( resp. status( ) . is_success( ) , "Could not download cookbook; HTTP status was {}" , resp. status( ) ) ;
112+ assert ! (
113+ resp. status( ) . is_success( ) ,
114+ "Could not download cookbook; HTTP status was {}" ,
115+ resp. status( ) ,
116+ ) ;
109117
110118 let mut content = String :: new ( ) ;
111119 resp. read_to_string ( & mut content)
@@ -212,14 +220,19 @@ fn playground_metadata_features(pkg: &Package) -> Option<(Vec<String>, bool)> {
212220 }
213221}
214222
215- pub fn generate_info ( modifications : & Modifications ) -> ( BTreeMap < String , DependencySpec > , Vec < CrateInformation > ) {
223+ pub fn generate_info (
224+ modifications : & Modifications ,
225+ ) -> ( BTreeMap < String , DependencySpec > , Vec < CrateInformation > ) {
216226 // Setup to interact with cargo.
217227 let config = Config :: default ( ) . expect ( "Unable to create default Cargo config" ) ;
218228 let _lock = config. acquire_package_cache_lock ( ) ;
219229 let crates_io = SourceId :: crates_io ( & config) . expect ( "Unable to create crates.io source ID" ) ;
220- let mut source = RegistrySource :: remote ( crates_io, & HashSet :: new ( ) , & config) . expect ( "Unable to create registry source" ) ;
230+ let mut source = RegistrySource :: remote ( crates_io, & HashSet :: new ( ) , & config)
231+ . expect ( "Unable to create registry source" ) ;
221232 source. invalidate_cache ( ) ;
222- source. block_until_ready ( ) . expect ( "Unable to wait for registry to be ready" ) ;
233+ source
234+ . block_until_ready ( )
235+ . expect ( "Unable to wait for registry to be ready" ) ;
223236
224237 let mut top = TopCrates :: download ( ) ;
225238 top. add_rust_cookbook_crates ( ) ;
@@ -272,11 +285,15 @@ pub fn generate_info(modifications: &Modifications) -> (BTreeMap<String, Depende
272285 . expect ( "Unable to resolve dependencies" ) ;
273286
274287 // Find crates incompatible with the playground's platform
275- let mut valid_for_our_platform: BTreeSet < _ > = summaries. iter ( ) . map ( |( s, _) | s. package_id ( ) ) . collect ( ) ;
288+ let mut valid_for_our_platform: BTreeSet < _ > =
289+ summaries. iter ( ) . map ( |( s, _) | s. package_id ( ) ) . collect ( ) ;
276290
277- let ct = CompileTarget :: new ( PLAYGROUND_TARGET_PLATFORM ) . expect ( "Unable to create a CompileTarget" ) ;
291+ let ct =
292+ CompileTarget :: new ( PLAYGROUND_TARGET_PLATFORM ) . expect ( "Unable to create a CompileTarget" ) ;
278293 let ck = CompileKind :: Target ( ct) ;
279- let rustc = config. load_global_rustc ( None ) . expect ( "Unable to load the global rustc" ) ;
294+ let rustc = config
295+ . load_global_rustc ( None )
296+ . expect ( "Unable to load the global rustc" ) ;
280297
281298 let ti = TargetInfo :: new ( & config, & [ ck] , & rustc, ck) . expect ( "Unable to create a TargetInfo" ) ;
282299 let cc = ti. cfg ( ) ;
@@ -288,9 +305,10 @@ pub fn generate_info(modifications: &Modifications) -> (BTreeMap<String, Depende
288305
289306 for package_id in to_visit {
290307 for ( dep_pkg, deps) in resolve. deps ( package_id) {
291-
292308 let for_this_platform = deps. iter ( ) . any ( |dep| {
293- dep. platform ( ) . map_or ( true , |platform| platform. matches ( PLAYGROUND_TARGET_PLATFORM , cc) )
309+ dep. platform ( ) . map_or ( true , |platform| {
310+ platform. matches ( PLAYGROUND_TARGET_PLATFORM , cc)
311+ } )
294312 } ) ;
295313
296314 if for_this_platform {
0 commit comments