@@ -46,11 +46,10 @@ pub fn remove(sess: &Session, path: &Path) {
4646/// Performs the linkage portion of the compilation phase. This will generate all
4747/// of the requested outputs for this compilation session.
4848pub fn link_binary < ' a , B : ArchiveBuilder < ' a > > ( sess : & ' a Session ,
49- codegen_results : & CodegenResults ,
50- outputs : & OutputFilenames ,
51- crate_name : & str ,
52- target_cpu : & str ) -> Vec < PathBuf > {
53- let mut out_filenames = Vec :: new ( ) ;
49+ codegen_results : & CodegenResults ,
50+ outputs : & OutputFilenames ,
51+ crate_name : & str ,
52+ target_cpu : & str ) {
5453 for & crate_type in sess. crate_types . borrow ( ) . iter ( ) {
5554 // Ignore executable crates if we have -Z no-codegen, as they will error.
5655 let output_metadata = sess. opts . output_types . contains_key ( & OutputType :: Metadata ) ;
@@ -64,13 +63,12 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
6463 bug ! ( "invalid output type `{:?}` for target os `{}`" ,
6564 crate_type, sess. opts. target_triple) ;
6665 }
67- let out_files = link_binary_output :: < B > ( sess,
68- codegen_results,
69- crate_type,
70- outputs,
71- crate_name,
72- target_cpu) ;
73- out_filenames. extend ( out_files) ;
66+ link_binary_output :: < B > ( sess,
67+ codegen_results,
68+ crate_type,
69+ outputs,
70+ crate_name,
71+ target_cpu) ;
7472 }
7573
7674 // Remove the temporary object file and metadata if we aren't saving temps
@@ -97,22 +95,18 @@ pub fn link_binary<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
9795 }
9896 }
9997 }
100-
101- out_filenames
10298}
10399
104100fn link_binary_output < ' a , B : ArchiveBuilder < ' a > > ( sess : & ' a Session ,
105- codegen_results : & CodegenResults ,
106- crate_type : config:: CrateType ,
107- outputs : & OutputFilenames ,
108- crate_name : & str ,
109- target_cpu : & str ) -> Vec < PathBuf > {
101+ codegen_results : & CodegenResults ,
102+ crate_type : config:: CrateType ,
103+ outputs : & OutputFilenames ,
104+ crate_name : & str ,
105+ target_cpu : & str ) {
110106 for obj in codegen_results. modules . iter ( ) . filter_map ( |m| m. object . as_ref ( ) ) {
111107 check_file_is_writeable ( obj, sess) ;
112108 }
113109
114- let mut out_filenames = vec ! [ ] ;
115-
116110 if outputs. outputs . contains_key ( & OutputType :: Metadata ) {
117111 let out_filename = filename_for_metadata ( sess, crate_name, outputs) ;
118112 // To avoid races with another rustc process scanning the output directory,
@@ -125,10 +119,15 @@ fn link_binary_output<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
125119 . tempdir_in ( out_filename. parent ( ) . unwrap ( ) )
126120 . unwrap_or_else ( |err| sess. fatal ( & format ! ( "couldn't create a temp dir: {}" , err) ) ) ;
127121 let metadata = emit_metadata ( sess, codegen_results, & metadata_tmpdir) ;
128- if let Err ( e) = fs:: rename ( metadata, & out_filename) {
129- sess. fatal ( & format ! ( "failed to write {}: {}" , out_filename. display( ) , e) ) ;
122+ match fs:: rename ( & metadata, & out_filename) {
123+ Ok ( _) => {
124+ if sess. opts . debugging_opts . emit_directives {
125+ sess. parse_sess . span_diagnostic . maybe_emit_json_directive (
126+ format ! ( "metadata file written: {}" , out_filename. display( ) ) ) ;
127+ }
128+ }
129+ Err ( e) => sess. fatal ( & format ! ( "failed to write {}: {}" , out_filename. display( ) , e) ) ,
130130 }
131- out_filenames. push ( out_filename) ;
132131 }
133132
134133 let tmpdir = TempFileBuilder :: new ( ) . prefix ( "rustc" ) . tempdir ( ) . unwrap_or_else ( |err|
@@ -158,14 +157,11 @@ fn link_binary_output<'a, B: ArchiveBuilder<'a>>(sess: &'a Session,
158157 ) ;
159158 }
160159 }
161- out_filenames. push ( out_filename) ;
162160 }
163161
164162 if sess. opts . cg . save_temps {
165163 let _ = tmpdir. into_path ( ) ;
166164 }
167-
168- out_filenames
169165}
170166
171167// The third parameter is for env vars, used on windows to set up the
0 commit comments