@@ -658,14 +658,18 @@ pub fn run_passes(sess: &Session,
658
658
}
659
659
660
660
// Produce final compile outputs.
661
+ let copy_gracefully = |from : & Path , to : & Path | {
662
+ if let Err ( e) = fs:: copy ( from, to) {
663
+ sess. err ( & format ! ( "could not copy {:?} to {:?}: {}" , from, to, e) ) ;
664
+ }
665
+ } ;
661
666
662
667
let copy_if_one_unit = |ext : & str , output_type : config:: OutputType , keep_numbered : bool | {
663
668
// Three cases:
664
669
if sess. opts . cg . codegen_units == 1 {
665
670
// 1) Only one codegen unit. In this case it's no difficulty
666
671
// to copy `foo.0.x` to `foo.x`.
667
- fs:: copy ( & crate_output. with_extension ( ext) ,
668
- & crate_output. path ( output_type) ) . unwrap ( ) ;
672
+ copy_gracefully ( & crate_output. with_extension ( ext) , & crate_output. path ( output_type) ) ;
669
673
if !sess. opts . cg . save_temps && !keep_numbered {
670
674
// The user just wants `foo.x`, not `foo.0.x`.
671
675
remove ( sess, & crate_output. with_extension ( ext) ) ;
@@ -687,8 +691,7 @@ pub fn run_passes(sess: &Session,
687
691
let link_obj = |output_path : & Path | {
688
692
// Running `ld -r` on a single input is kind of pointless.
689
693
if sess. opts . cg . codegen_units == 1 {
690
- fs:: copy ( & crate_output. with_extension ( "0.o" ) ,
691
- output_path) . unwrap ( ) ;
694
+ copy_gracefully ( & crate_output. with_extension ( "0.o" ) , output_path) ;
692
695
// Leave the .0.o file around, to mimic the behavior of the normal
693
696
// code path.
694
697
return ;
0 commit comments