Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions compiler/rustc_codegen_ssa/src/back/link.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,18 @@ pub fn link_binary(
});

if outputs.outputs.should_link() {
let tmpdir = TempDirBuilder::new()
.prefix("rustc")
.tempdir()
.unwrap_or_else(|error| sess.dcx().emit_fatal(errors::CreateTempDir { error }));
let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps);
let output = out_filename(
sess,
crate_type,
outputs,
codegen_results.crate_info.local_crate_name,
);
let tmpdir = TempDirBuilder::new()
.prefix("rustc")
.tempdir_in(output.parent().unwrap_or_else(|| Path::new(".")))
.unwrap_or_else(|error| sess.dcx().emit_fatal(errors::CreateTempDir { error }));
let path = MaybeTempDir::new(tmpdir, sess.opts.cg.save_temps);

let crate_name = format!("{}", codegen_results.crate_info.local_crate_name);
let out_filename = output.file_for_writing(
outputs,
Expand Down
6 changes: 1 addition & 5 deletions compiler/rustc_fs_util/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use std::ffi::{CString, OsStr};
use std::path::{Path, PathBuf, absolute};
use std::{env, fs, io};
use std::{fs, io};

use tempfile::TempDir;

Expand Down Expand Up @@ -139,8 +139,4 @@ impl<'a, 'b> TempDirBuilder<'a, 'b> {
}
self.builder.tempdir_in(dir)
}

pub fn tempdir(&self) -> io::Result<TempDir> {
self.tempdir_in(env::temp_dir())
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
//@ needs-target-std
//
// When the TMP (on Windows) or TMPDIR (on Unix) variable is set to an invalid
// or non-existing directory, this used to cause an internal compiler error (ICE). After the
// addition of proper error handling in #28430, this test checks that the expected message is
// printed.
// or non-existing directory, this used to cause an internal compiler error (ICE).
// See https://github.com/rust-lang/rust/issues/14698

use run_make_support::{is_windows, rustc};
Expand All @@ -18,5 +16,9 @@ fn main() {
} else {
rustc.env("TMPDIR", "fake");
}
rustc.input("foo.rs").run_fail().assert_stderr_contains("couldn't create a temp dir");
let result = rustc.input("foo.rs").run_unchecked();
// Ensure that rustc doesn't ICE.
if !result.status().success() {
result.assert_stderr_not_contains("internal compiler error");
}
}
Loading