@@ -2215,7 +2215,7 @@ pub fn translate_dep_info(
2215
2215
#[ derive( Default ) ]
2216
2216
pub struct RustcDepInfo {
2217
2217
/// The list of files that the main target in the dep-info file depends on.
2218
- pub files : Vec < ( PathBuf , Option < ( u64 , Checksum ) > ) > ,
2218
+ pub files : HashMap < PathBuf , Option < ( u64 , Checksum ) > > ,
2219
2219
/// The list of environment variables we found that the rustc compilation
2220
2220
/// depends on.
2221
2221
///
@@ -2379,38 +2379,37 @@ pub fn parse_rustc_dep_info(rustc_dep_info: &Path) -> CargoResult<RustcDepInfo>
2379
2379
if found_deps {
2380
2380
continue ;
2381
2381
}
2382
- let mut parsing_checksum_index = None ;
2383
- let mut last_seen_checksum = None ;
2384
2382
found_deps = true ;
2385
2383
let mut deps = line[ pos + 2 ..] . split_whitespace ( ) ;
2386
2384
2387
2385
while let Some ( s) = deps. next ( ) {
2388
- let mut word = s. to_string ( ) ;
2389
- if word == "#" {
2390
- parsing_checksum_index = Some ( 0 ) ;
2391
- continue ;
2392
- }
2393
- while word. ends_with ( '\\' ) {
2394
- word. pop ( ) ;
2395
- word. push ( ' ' ) ;
2396
- word. push_str ( deps. next ( ) . ok_or_else ( || {
2386
+ let mut file = s. to_string ( ) ;
2387
+ while file. ends_with ( '\\' ) {
2388
+ file. pop ( ) ;
2389
+ file. push ( ' ' ) ;
2390
+ file. push_str ( deps. next ( ) . ok_or_else ( || {
2397
2391
internal ( "malformed dep-info format, trailing \\ " . to_string ( ) )
2398
2392
} ) ?) ;
2399
2393
}
2400
- if let Some ( parsing_checksum_index) = parsing_checksum_index. as_mut ( ) {
2401
- // By now files list is built, checksum data is provided in the same order as
2402
- // the file list
2403
- if let Some ( checksum) = word. strip_prefix ( "checksum:" ) {
2404
- last_seen_checksum = Some ( Checksum :: from_str ( checksum) ?) ;
2405
- } else if let Some ( file_len) = word. strip_prefix ( "file_len:" ) {
2406
- let file_len = file_len. parse :: < u64 > ( ) ?;
2407
- let file_entry = & mut ret. files [ * parsing_checksum_index] ;
2408
- file_entry. 1 = last_seen_checksum. take ( ) . map ( |c| ( file_len, c) ) ;
2409
- * parsing_checksum_index += 1 ;
2410
- }
2411
- } else {
2412
- ret. files . push ( ( word. into ( ) , None ) ) ;
2413
- }
2394
+ ret. files . insert ( file. into ( ) , None ) ;
2395
+ }
2396
+ } else if let Some ( rest) = line. strip_prefix ( "# checksum:" ) {
2397
+ let mut parts = rest. splitn ( 3 , ' ' ) ;
2398
+ let Some ( checksum) = parts. next ( ) . map ( Checksum :: from_str) . transpose ( ) ? else {
2399
+ continue ;
2400
+ } ;
2401
+ let Some ( Ok ( file_len) ) = parts
2402
+ . next ( )
2403
+ . and_then ( |s| s. strip_prefix ( "file_len:" ) . map ( |s| s. parse :: < u64 > ( ) ) )
2404
+ else {
2405
+ continue ;
2406
+ } ;
2407
+ let Some ( path) = parts. next ( ) . map ( PathBuf :: from) else {
2408
+ continue ;
2409
+ } ;
2410
+
2411
+ if let Some ( entry) = ret. files . get_mut ( & path) {
2412
+ * entry = Some ( ( file_len, checksum) ) ;
2414
2413
}
2415
2414
}
2416
2415
}
0 commit comments