diff --git a/compiler/rustc_interface/src/passes.rs b/compiler/rustc_interface/src/passes.rs index a8afb8c2900..b9b65755db5 100644 --- a/compiler/rustc_interface/src/passes.rs +++ b/compiler/rustc_interface/src/passes.rs @@ -536,9 +536,9 @@ fn hash_iter_files>( let write_deps_to_file = |file: &mut dyn Write| -> io::Result<()> { for path in out_filenames { - write!( + writeln!( file, - "{}: {}", + "{}: {}\n", path.display(), files .iter() @@ -546,25 +546,6 @@ fn hash_iter_files>( .intersperse(" ") .collect::() )?; - - // If caller requested this information, add special comments about source file checksums. - // These are not necessarily the same checksums as was used in the debug files. - if sess.opts.unstable_opts.checksum_hash_algorithm().is_some() { - assert!( - files.iter().all(|(_path, _file_len, hash_algo)| hash_algo.is_some()), - "all files must have a checksum hash computed to output checksum hashes" - ); - write!(file, " #")?; - files - .iter() - .filter_map(|(_path, file_len, hash_algo)| { - hash_algo.map(|hash_algo| (path, file_len, hash_algo)) - }) - .try_for_each(|(_path, file_len, checksum_hash)| { - write!(file, " checksum:{checksum_hash} file_len:{file_len}") - })?; - } - write!(file, "\n\n")?; } // Emit a fake target for each input file to the compilation. This @@ -594,6 +575,18 @@ fn hash_iter_files>( } } + // If caller requested this information, add special comments about source file checksums. + // These are not necessarily the same checksums as was used in the debug files. + if sess.opts.unstable_opts.checksum_hash_algorithm().is_some() { + for (path, file_len, checksum_hash) in + files.iter().filter_map(|(path, file_len, hash_algo)| { + hash_algo.map(|hash_algo| (path, file_len, hash_algo)) + }) + { + writeln!(file, "# checksum:{checksum_hash} file_len:{file_len} {path}")?; + } + } + Ok(()) }; diff --git a/tests/run-make/checksum-freshness/expected.d b/tests/run-make/checksum-freshness/expected.d index 4b10e293229..51467af53a2 100644 --- a/tests/run-make/checksum-freshness/expected.d +++ b/tests/run-make/checksum-freshness/expected.d @@ -1,4 +1,6 @@ -lib.d: lib.rs foo.rs # checksum:blake3=94af75ee4ed805434484c3de51c9025278e5c3ada2315e2592052e102168a503 file_len:120 checksum:blake3=2720e17bfda4f3b2a5c96bb61b7e76ed8ebe3359b34128c0e5d8032c090a4f1a file_len:119 +lib.d: lib.rs foo.rs lib.rs: foo.rs: +# checksum:blake3=94af75ee4ed805434484c3de51c9025278e5c3ada2315e2592052e102168a503 file_len:120 lib.rs +# checksum:blake3=2720e17bfda4f3b2a5c96bb61b7e76ed8ebe3359b34128c0e5d8032c090a4f1a file_len:119 foo.rs