Skip to content

Commit d407903

Browse files
committed
Rollup merge of #28430 - apasel422:issue-14698, r=alexcrichton
Emit an error upon failing to create a temp dir instead of panicking Closes #14698.
2 parents 6872d13 + 7352722 commit d407903

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/librustc_trans/back/link.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,11 @@ fn link_binary_output(sess: &Session,
542542
}
543543
}
544544

545-
let tmpdir = TempDir::new("rustc").ok().expect("needs a temp dir");
545+
let tmpdir = match TempDir::new("rustc") {
546+
Ok(tmpdir) => tmpdir,
547+
Err(err) => sess.fatal(&format!("couldn't create a temp dir: {}", err)),
548+
};
549+
546550
match crate_type {
547551
config::CrateTypeRlib => {
548552
link_rlib(sess, Some(trans), &objects, &out_filename,
Lines changed: 4 additions & 0 deletions
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

Lines changed: 11 additions & 0 deletions
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)