@@ -536,7 +536,7 @@ 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- writeln ! (
539+ write ! (
540540 file,
541541 "{}: {}\n " ,
542542 path. display( ) ,
@@ -546,6 +546,25 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
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+ writeln ! ( file) ?;
549568 }
550569
551570 // Emit a fake target for each input file to the compilation. This
@@ -575,18 +594,6 @@ fn write_out_deps(tcx: TyCtxt<'_>, outputs: &OutputFilenames, out_filenames: &[P
575594 }
576595 }
577596
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-
590597 Ok ( ( ) )
591598 } ;
592599
0 commit comments