@@ -2,11 +2,11 @@ use super::link::{self, ensure_removed};
22use super :: lto:: { self , SerializedModule } ;
33use super :: symbol_export:: symbol_name_for_instance_in_crate;
44
5+ use crate :: errors;
6+ use crate :: traits:: * ;
57use crate :: {
68 CachedModuleCodegen , CodegenResults , CompiledModule , CrateInfo , ModuleCodegen , ModuleKind ,
79} ;
8-
9- use crate :: traits:: * ;
1010use jobserver:: { Acquired , Client } ;
1111use rustc_data_structures:: fx:: FxHashMap ;
1212use rustc_data_structures:: memmap:: Mmap ;
@@ -530,7 +530,7 @@ fn produce_final_output_artifacts(
530530 // Produce final compile outputs.
531531 let copy_gracefully = |from : & Path , to : & Path | {
532532 if let Err ( e) = fs:: copy ( from, to) {
533- sess. err ( & format ! ( "could not copy {:?} to {:?}: {}" , from, to, e) ) ;
533+ sess. emit_err ( errors :: CopyPath :: new ( from, to, e) ) ;
534534 }
535535 } ;
536536
@@ -546,7 +546,7 @@ fn produce_final_output_artifacts(
546546 ensure_removed ( sess. diagnostic ( ) , & path) ;
547547 }
548548 } else {
549- let ext = crate_output
549+ let extension = crate_output
550550 . temp_path ( output_type, None )
551551 . extension ( )
552552 . unwrap ( )
@@ -557,19 +557,11 @@ fn produce_final_output_artifacts(
557557 if crate_output. outputs . contains_key ( & output_type) {
558558 // 2) Multiple codegen units, with `--emit foo=some_name`. We have
559559 // no good solution for this case, so warn the user.
560- sess. warn ( & format ! (
561- "ignoring emit path because multiple .{} files \
562- were produced",
563- ext
564- ) ) ;
560+ sess. emit_warning ( errors:: IgnoringEmitPath { extension } ) ;
565561 } else if crate_output. single_output_file . is_some ( ) {
566562 // 3) Multiple codegen units, with `-o some_name`. We have
567563 // no good solution for this case, so warn the user.
568- sess. warn ( & format ! (
569- "ignoring -o because multiple .{} files \
570- were produced",
571- ext
572- ) ) ;
564+ sess. emit_warning ( errors:: IgnoringOutput { extension } ) ;
573565 } else {
574566 // 4) Multiple codegen units, but no explicit name. We
575567 // just leave the `foo.0.x` files in place.
@@ -880,14 +872,19 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
880872 ) ;
881873 match link_or_copy ( & source_file, & output_path) {
882874 Ok ( _) => Some ( output_path) ,
883- Err ( err) => {
884- let diag_handler = cgcx. create_diag_handler ( ) ;
885- diag_handler. err ( & format ! (
886- "unable to copy {} to {}: {}" ,
887- source_file. display( ) ,
888- output_path. display( ) ,
889- err
890- ) ) ;
875+ Err ( _) => {
876+ // FIXME:
877+ // Should we add Translations support in Handler, or should we pass a session here ?
878+ //
879+ // As Luis Cardoso mentioned here https://github.com/rust-lang/rust/pull/100753#discussion_r952975345,
880+ // Translations support in Handler is tricky because SessionDiagnostic is not a trait,
881+ // and we can't implement it in Handler because rustc_errors cannot depend on rustc_session.
882+ //
883+ // As for passing a session here, my understanding is that all these errors should be reported via
884+ // the Shared Handler, which leads us to probably having to support Translations in another way.
885+
886+ // let diag_handler = cgcx.create_diag_handler();
887+ // diag_handler.emit_err(errors::CopyPathBuf { source_file, output_path, error });
891888 None
892889 }
893890 }
0 commit comments