@@ -20,14 +20,17 @@ use serde_json::Value;
20
20
// use this to store the crates when interacting with the crates.toml file
21
21
#[ derive( Debug , Serialize , Deserialize ) ]
22
22
struct CrateList {
23
- crates : HashMap < String , Vec < String > > ,
23
+ crates : HashMap < String , TomlCrate > ,
24
24
}
25
25
26
26
// crate data we stored in the toml, can have multiple versions per crate
27
27
// A single TomlCrate is laster mapped to several CrateSources in that case
28
+ #[ derive( Debug , Serialize , Deserialize ) ]
28
29
struct TomlCrate {
29
30
name : String ,
30
- versions : Vec < String > ,
31
+ versions : Option < Vec < String > > ,
32
+ git_url : Option < String > ,
33
+ git_hash : Option < String > ,
31
34
}
32
35
33
36
// represents an archive we download from crates.io
@@ -114,7 +117,7 @@ impl Crate {
114
117
115
118
let shared_target_dir = clippy_project_root ( ) . join ( "target/lintcheck/shared_target_dir/" ) ;
116
119
117
- let all_output = std:: process:: Command :: new ( cargo_clippy_path)
120
+ let all_output = std:: process:: Command :: new ( & cargo_clippy_path)
118
121
. env ( "CARGO_TARGET_DIR" , shared_target_dir)
119
122
// lint warnings will look like this:
120
123
// src/cargo/ops/cargo_compile.rs:127:35: warning: usage of `FromIterator::from_iter`
@@ -128,7 +131,12 @@ impl Crate {
128
131
] )
129
132
. current_dir ( & self . path )
130
133
. 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
+ } ) ;
132
140
let stdout = String :: from_utf8_lossy ( & all_output. stdout ) ;
133
141
let output_lines = stdout. lines ( ) ;
134
142
//dbg!(&output_lines);
@@ -160,19 +168,21 @@ fn read_crates() -> Vec<CrateSource> {
160
168
let tomlcrates: Vec < TomlCrate > = crate_list
161
169
. crates
162
170
. into_iter ( )
163
- . map ( |( name , versions ) | TomlCrate { name , versions } )
171
+ . map ( |( _cratename , tomlcrate ) | tomlcrate )
164
172
. collect ( ) ;
165
173
166
174
// flatten TomlCrates into CrateSources (one TomlCrates may represent several versions of a crate =>
167
175
// multiple Cratesources)
168
176
let mut crate_sources = Vec :: new ( ) ;
169
177
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
+ }
176
186
} ) ;
177
187
crate_sources
178
188
}
0 commit comments