Skip to content

Commit 7352722

Browse files
committed
Emit an error upon failing to create a temp dir instead of panicking
Closes #14698.
1 parent 3887ca2 commit 7352722

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/librustc_trans/back/link.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,11 @@ fn link_binary_output(sess: &Session,
543543
}
544544
}
545545

546-
let tmpdir = TempDir::new("rustc").ok().expect("needs a temp dir");
546+
let tmpdir = match TempDir::new("rustc") {
547+
Ok(tmpdir) => tmpdir,
548+
Err(err) => sess.fatal(&format!("couldn't create a temp dir: {}", err)),
549+
};
550+
547551
match crate_type {
548552
config::CrateTypeRlib => {
549553
link_rlib(sess, Some(trans), &objects, &out_filename,
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
-include ../tools.mk
2+
3+
all:
4+
TMP=fake TMPDIR=fake $(RUSTC) foo.rs 2>&1 | grep "couldn't create a temp dir:"

src/test/run-make/issue-14698/foo.rs

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
fn main() {}

0 commit comments

Comments
 (0)