@@ -20,14 +20,17 @@ use serde_json::Value;
2020// use this to store the crates when interacting with the crates.toml file
2121#[ derive( Debug , Serialize , Deserialize ) ]
2222struct CrateList {
23- crates : HashMap < String , Vec < String > > ,
23+ crates : HashMap < String , TomlCrate > ,
2424}
2525
2626// crate data we stored in the toml, can have multiple versions per crate
2727// A single TomlCrate is laster mapped to several CrateSources in that case
28+ #[ derive( Debug , Serialize , Deserialize ) ]
2829struct TomlCrate {
2930 name : String ,
30- versions : Vec < String > ,
31+ versions : Option < Vec < String > > ,
32+ git_url : Option < String > ,
33+ git_hash : Option < String > ,
3134}
3235
3336// represents an archive we download from crates.io
@@ -114,7 +117,7 @@ impl Crate {
114117
115118 let shared_target_dir = clippy_project_root ( ) . join ( "target/lintcheck/shared_target_dir/" ) ;
116119
117- let all_output = std:: process:: Command :: new ( cargo_clippy_path)
120+ let all_output = std:: process:: Command :: new ( & cargo_clippy_path)
118121 . env ( "CARGO_TARGET_DIR" , shared_target_dir)
119122 // lint warnings will look like this:
120123 // src/cargo/ops/cargo_compile.rs:127:35: warning: usage of `FromIterator::from_iter`
@@ -128,7 +131,12 @@ impl Crate {
128131 ] )
129132 . current_dir ( & self . path )
130133 . output ( )
131- . unwrap ( ) ;
134+ . unwrap_or_else ( |error| {
135+ dbg ! ( error) ;
136+ dbg ! ( & cargo_clippy_path) ;
137+ dbg ! ( & self . path) ;
138+ panic ! ( "something was not found?" )
139+ } ) ;
132140 let stdout = String :: from_utf8_lossy ( & all_output. stdout ) ;
133141 let output_lines = stdout. lines ( ) ;
134142 //dbg!(&output_lines);
@@ -160,19 +168,21 @@ fn read_crates() -> Vec<CrateSource> {
160168 let tomlcrates: Vec < TomlCrate > = crate_list
161169 . crates
162170 . into_iter ( )
163- . map ( |( name , versions ) | TomlCrate { name , versions } )
171+ . map ( |( _cratename , tomlcrate ) | tomlcrate )
164172 . collect ( ) ;
165173
166174 // flatten TomlCrates into CrateSources (one TomlCrates may represent several versions of a crate =>
167175 // multiple Cratesources)
168176 let mut crate_sources = Vec :: new ( ) ;
169177 tomlcrates. into_iter ( ) . for_each ( |tk| {
170- tk. versions . iter ( ) . for_each ( |ver| {
171- crate_sources. push ( CrateSource {
172- name : tk. name . clone ( ) ,
173- version : ver. to_string ( ) ,
174- } ) ;
175- } )
178+ if let Some ( ref versions) = tk. versions {
179+ versions. iter ( ) . for_each ( |ver| {
180+ crate_sources. push ( CrateSource {
181+ name : tk. name . clone ( ) ,
182+ version : ver. to_string ( ) ,
183+ } ) ;
184+ } )
185+ }
176186 } ) ;
177187 crate_sources
178188}
0 commit comments