]> git.lizzy.rs Git - rust.git/commitdiff
Emit an error upon failing to create a temp dir instead of panicking
authorAndrew Paseltiner <apaseltiner@gmail.com>
Wed, 16 Sep 2015 17:52:02 +0000 (13:52 -0400)
committerAndrew Paseltiner <apaseltiner@gmail.com>
Wed, 16 Sep 2015 17:52:02 +0000 (13:52 -0400)
Closes #14698.

src/librustc_trans/back/link.rs
src/test/run-make/issue-14698/Makefile [new file with mode: 0644]
src/test/run-make/issue-14698/foo.rs [new file with mode: 0644]

index d5486e84fc43123fc8bdbe99f94931f1e581af71..fdce46ba272a20431803c1062cce34de4de0e510 100644 (file)
@@ -543,7 +543,11 @@ fn link_binary_output(sess: &Session,
         }
     }
 
-    let tmpdir = TempDir::new("rustc").ok().expect("needs a temp dir");
+    let tmpdir = match TempDir::new("rustc") {
+        Ok(tmpdir) => tmpdir,
+        Err(err) => sess.fatal(&format!("couldn't create a temp dir: {}", err)),
+    };
+
     match crate_type {
         config::CrateTypeRlib => {
             link_rlib(sess, Some(trans), &objects, &out_filename,
diff --git a/src/test/run-make/issue-14698/Makefile b/src/test/run-make/issue-14698/Makefile
new file mode 100644 (file)
index 0000000..28502f6
--- /dev/null
@@ -0,0 +1,4 @@
+-include ../tools.mk
+
+all:
+       TMP=fake TMPDIR=fake $(RUSTC) foo.rs 2>&1 | grep "couldn't create a temp dir:"
diff --git a/src/test/run-make/issue-14698/foo.rs b/src/test/run-make/issue-14698/foo.rs
new file mode 100644 (file)
index 0000000..7dc79f2
--- /dev/null
@@ -0,0 +1,11 @@
+// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
+// file at the top-level directory of this distribution and at
+// http://rust-lang.org/COPYRIGHT.
+//
+// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
+// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
+// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
+// option. This file may not be copied, modified, or distributed
+// except according to those terms.
+
+fn main() {}