about summary refs log tree commit diff
diff options
context:
space:
mode:
authorJacob Kiesel <jake@bitcrafters.co>2024-10-01 23:05:24 -0600
committerJacob Kiesel <jake@bitcrafters.co>2024-10-01 23:05:24 -0600
commitb48c5f19e07c46d43d03328c86d3f7af6f9c8187 (patch)
treeaa41aebab8de091f10921c4b816d0cc4e18e6e28
parent15efbc6e8d78b257f594ddfb64d215c9ac3bee6d (diff)
downloadrust-b48c5f19e07c46d43d03328c86d3f7af6f9c8187.tar.gz
rust-b48c5f19e07c46d43d03328c86d3f7af6f9c8187.zip
Restore prior behavior with less duplicate info in dep file
-rw-r--r--compiler/rustc_interface/src/passes.rs35
-rw-r--r--tests/run-make/checksum-freshness/expected.d4
2 files changed, 17 insertions, 22 deletions
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 write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
 
         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 write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
                         .intersperse(" ")
                         .collect::<String>()
                 )?;
-
-                // 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 write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
                 }
             }
 
+            // 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