Skip to content

Commit b48c5f1

Browse files
committed
Restore prior behavior with less duplicate info in dep file
1 parent 15efbc6 commit b48c5f1

File tree

2 files changed

+17
-22
lines changed

2 files changed

+17
-22
lines changed

compiler/rustc_interface/src/passes.rs

+14-21
Original file line numberDiff line numberDiff line change
@@ -536,35 +536,16 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
536536

537537
let write_deps_to_file = |file: &mut dyn Write| -> io::Result<()> {
538538
for path in out_filenames {
539-
write!(
539+
writeln!(
540540
file,
541-
"{}: {}",
541+
"{}: {}\n",
542542
path.display(),
543543
files
544544
.iter()
545545
.map(|(path, _file_len, _checksum_hash_algo)| path.as_str())
546546
.intersperse(" ")
547547
.collect::<String>()
548548
)?;
549-
550-
// If caller requested this information, add special comments about source file checksums.
551-
// These are not necessarily the same checksums as was used in the debug files.
552-
if sess.opts.unstable_opts.checksum_hash_algorithm().is_some() {
553-
assert!(
554-
files.iter().all(|(_path, _file_len, hash_algo)| hash_algo.is_some()),
555-
"all files must have a checksum hash computed to output checksum hashes"
556-
);
557-
write!(file, " #")?;
558-
files
559-
.iter()
560-
.filter_map(|(_path, file_len, hash_algo)| {
561-
hash_algo.map(|hash_algo| (path, file_len, hash_algo))
562-
})
563-
.try_for_each(|(_path, file_len, checksum_hash)| {
564-
write!(file, " checksum:{checksum_hash} file_len:{file_len}")
565-
})?;
566-
}
567-
write!(file, "\n\n")?;
568549
}
569550

570551
// Emit a fake target for each input file to the compilation. This
@@ -594,6 +575,18 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
594575
}
595576
}
596577

578+
// If caller requested this information, add special comments about source file checksums.
579+
// These are not necessarily the same checksums as was used in the debug files.
580+
if sess.opts.unstable_opts.checksum_hash_algorithm().is_some() {
581+
for (path, file_len, checksum_hash) in
582+
files.iter().filter_map(|(path, file_len, hash_algo)| {
583+
hash_algo.map(|hash_algo| (path, file_len, hash_algo))
584+
})
585+
{
586+
writeln!(file, "# checksum:{checksum_hash} file_len:{file_len} {path}")?;
587+
}
588+
}
589+
597590
Ok(())
598591
};
599592

Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
lib.d: lib.rs foo.rs # checksum:blake3=94af75ee4ed805434484c3de51c9025278e5c3ada2315e2592052e102168a503 file_len:120 checksum:blake3=2720e17bfda4f3b2a5c96bb61b7e76ed8ebe3359b34128c0e5d8032c090a4f1a file_len:119
1+
lib.d: lib.rs foo.rs
22

33
lib.rs:
44
foo.rs:
5+
# checksum:blake3=94af75ee4ed805434484c3de51c9025278e5c3ada2315e2592052e102168a503 file_len:120 lib.rs
6+
# checksum:blake3=2720e17bfda4f3b2a5c96bb61b7e76ed8ebe3359b34128c0e5d8032c090a4f1a file_len:119 foo.rs

0 commit comments

Comments
 (0)