@@ -2,11 +2,11 @@ use super::link::{self, ensure_removed};
2
2
use super :: lto:: { self , SerializedModule } ;
3
3
use super :: symbol_export:: symbol_name_for_instance_in_crate;
4
4
5
+ use crate :: errors;
6
+ use crate :: traits:: * ;
5
7
use crate :: {
6
8
CachedModuleCodegen , CodegenResults , CompiledModule , CrateInfo , ModuleCodegen , ModuleKind ,
7
9
} ;
8
-
9
- use crate :: traits:: * ;
10
10
use jobserver:: { Acquired , Client } ;
11
11
use rustc_data_structures:: fx:: FxHashMap ;
12
12
use rustc_data_structures:: memmap:: Mmap ;
@@ -530,7 +530,7 @@ fn produce_final_output_artifacts(
530
530
// Produce final compile outputs.
531
531
let copy_gracefully = |from : & Path , to : & Path | {
532
532
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) ) ;
534
534
}
535
535
} ;
536
536
@@ -546,7 +546,7 @@ fn produce_final_output_artifacts(
546
546
ensure_removed ( sess. diagnostic ( ) , & path) ;
547
547
}
548
548
} else {
549
- let ext = crate_output
549
+ let extension = crate_output
550
550
. temp_path ( output_type, None )
551
551
. extension ( )
552
552
. unwrap ( )
@@ -557,19 +557,11 @@ fn produce_final_output_artifacts(
557
557
if crate_output. outputs . contains_key ( & output_type) {
558
558
// 2) Multiple codegen units, with `--emit foo=some_name`. We have
559
559
// 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 } ) ;
565
561
} else if crate_output. single_output_file . is_some ( ) {
566
562
// 3) Multiple codegen units, with `-o some_name`. We have
567
563
// 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 } ) ;
573
565
} else {
574
566
// 4) Multiple codegen units, but no explicit name. We
575
567
// just leave the `foo.0.x` files in place.
@@ -880,14 +872,19 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
880
872
) ;
881
873
match link_or_copy ( & source_file, & output_path) {
882
874
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 });
891
888
None
892
889
}
893
890
}
0 commit comments