about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorAlex Crichton <alex@alexcrichton.com>2015-02-11 14:02:06 -0800
committerAlex Crichton <alex@alexcrichton.com>2015-02-11 14:02:06 -0800
commit18d31cc14b4da433efa72a44ba326485e2f39b04 (patch)
tree8153d01a547d4b46f486e65de7e9ba756ab743a1 /src
parent84e5c11785719bcf07c54dbd58284bed5c664c5c (diff)
parenta941fdb98dce04be3a6e3be739a71e513d2b1d81 (diff)
downloadrust-18d31cc14b4da433efa72a44ba326485e2f39b04.tar.gz
rust-18d31cc14b4da433efa72a44ba326485e2f39b04.zip
rollup merge of #22150: nagisa/de-perm-frost
Fixes #22124
Diffstat (limited to 'src')
-rw-r--r--src/librustc_trans/back/write.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/librustc_trans/back/write.rs b/src/librustc_trans/back/write.rs
index 8a30806f3b6..68f413eff85 100644
--- a/src/librustc_trans/back/write.rs
+++ b/src/librustc_trans/back/write.rs
@@ -658,14 +658,18 @@ pub fn run_passes(sess: &Session,
     }
 
     // Produce final compile outputs.
+    let copy_gracefully = |from: &Path, to: &Path| {
+        if let Err(e) = fs::copy(from, to) {
+            sess.err(&format!("could not copy {:?} to {:?}: {}", from, to, e));
+        }
+    };
 
     let copy_if_one_unit = |ext: &str, output_type: config::OutputType, keep_numbered: bool| {
         // Three cases:
         if sess.opts.cg.codegen_units == 1 {
             // 1) Only one codegen unit.  In this case it's no difficulty
             //    to copy `foo.0.x` to `foo.x`.
-            fs::copy(&crate_output.with_extension(ext),
-                     &crate_output.path(output_type)).unwrap();
+            copy_gracefully(&crate_output.with_extension(ext), &crate_output.path(output_type));
             if !sess.opts.cg.save_temps && !keep_numbered {
                 // The user just wants `foo.x`, not `foo.0.x`.
                 remove(sess, &crate_output.with_extension(ext));
@@ -687,8 +691,7 @@ pub fn run_passes(sess: &Session,
     let link_obj = |output_path: &Path| {
         // Running `ld -r` on a single input is kind of pointless.
         if sess.opts.cg.codegen_units == 1 {
-            fs::copy(&crate_output.with_extension("0.o"),
-                     output_path).unwrap();
+            copy_gracefully(&crate_output.with_extension("0.o"), output_path);
             // Leave the .0.o file around, to mimic the behavior of the normal
             // code path.
             return;