Skip to content

Commit 20ad958

Browse files
committed
replace tmp_dir().join(_) with tmp_path(_)
1 parent 91c0823 commit 20ad958

File tree

39 files changed

+102
-96
lines changed

39 files changed

+102
-96
lines changed

src/tools/run-make-support/src/cc.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ use std::env;
22
use std::path::Path;
33
use std::process::Command;
44

5-
use crate::{bin_name, cygpath_windows, handle_failed_output, is_msvc, is_windows, tmp_dir, uname};
5+
use crate::{
6+
bin_name, cygpath_windows, handle_failed_output, is_msvc, is_windows, tmp_path, uname,
7+
};
68

79
/// Construct a new platform-specific C compiler invocation.
810
///
@@ -68,13 +70,13 @@ impl Cc {
6870
// ```
6971

7072
if is_msvc() {
71-
let fe_path = cygpath_windows(tmp_dir().join(bin_name(name)));
72-
let fo_path = cygpath_windows(tmp_dir().join(format!("{name}.obj")));
73+
let fe_path = cygpath_windows(tmp_path(bin_name(name)));
74+
let fo_path = cygpath_windows(tmp_path(format!("{name}.obj")));
7375
self.cmd.arg(format!("-Fe:{fe_path}"));
7476
self.cmd.arg(format!("-Fo:{fo_path}"));
7577
} else {
7678
self.cmd.arg("-o");
77-
self.cmd.arg(tmp_dir().join(name));
79+
self.cmd.arg(tmp_path(name));
7880
}
7981

8082
self

src/tools/run-make-support/src/clang.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use std::env;
22
use std::path::Path;
33
use std::process::Command;
44

5-
use crate::{bin_name, handle_failed_output, tmp_dir};
5+
use crate::{bin_name, handle_failed_output, tmp_path};
66

77
/// Construct a new `clang` invocation. `clang` is not always available for all targets.
88
pub fn clang() -> Clang {
@@ -36,7 +36,7 @@ impl Clang {
3636
/// extension will be determined by [`bin_name`].
3737
pub fn out_exe(&mut self, name: &str) -> &mut Self {
3838
self.cmd.arg("-o");
39-
self.cmd.arg(tmp_dir().join(bin_name(name)));
39+
self.cmd.arg(tmp_path(bin_name(name)));
4040
self
4141
}
4242

src/tools/run-make-support/src/lib.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@ pub fn tmp_dir() -> PathBuf {
3535
env::var_os("TMPDIR").unwrap().into()
3636
}
3737

38+
pub fn tmp_path<P: AsRef<Path>>(path: P) -> PathBuf {
39+
tmp_dir().join(path.as_ref())
40+
}
41+
3842
/// `TARGET`
3943
pub fn target() -> String {
4044
env::var("TARGET").unwrap()
@@ -58,7 +62,7 @@ pub fn is_darwin() -> bool {
5862
/// Construct a path to a static library under `$TMPDIR` given the library name. This will return a
5963
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
6064
pub fn static_lib(name: &str) -> PathBuf {
61-
tmp_dir().join(static_lib_name(name))
65+
tmp_path(static_lib_name(name))
6266
}
6367

6468
pub fn python_command() -> Command {
@@ -103,7 +107,7 @@ pub fn static_lib_name(name: &str) -> String {
103107
/// Construct a path to a dynamic library under `$TMPDIR` given the library name. This will return a
104108
/// path with `$TMPDIR` joined with platform-and-compiler-specific library name.
105109
pub fn dynamic_lib(name: &str) -> PathBuf {
106-
tmp_dir().join(dynamic_lib_name(name))
110+
tmp_path(dynamic_lib_name(name))
107111
}
108112

109113
/// Construct the dynamic library name based on the platform.
@@ -135,7 +139,7 @@ pub fn dynamic_lib_name(name: &str) -> String {
135139
/// Construct a path to a rust library (rlib) under `$TMPDIR` given the library name. This will return a
136140
/// path with `$TMPDIR` joined with the library name.
137141
pub fn rust_lib(name: &str) -> PathBuf {
138-
tmp_dir().join(rust_lib_name(name))
142+
tmp_path(rust_lib_name(name))
139143
}
140144

141145
/// Generate the name a rust library (rlib) would have. If you want the complete path, use

tests/run-make/compiler-builtins/rmake.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use run_make_support::object::ObjectSection;
2121
use run_make_support::object::ObjectSymbol;
2222
use run_make_support::object::RelocationTarget;
2323
use run_make_support::set_host_rpath;
24-
use run_make_support::tmp_dir;
24+
use run_make_support::tmp_path;
2525
use std::collections::HashSet;
2626

2727
const MANIFEST: &str = r#"
@@ -34,15 +34,15 @@ edition = "2021"
3434
path = "lib.rs""#;
3535

3636
fn main() {
37-
let target_dir = tmp_dir().join("target");
37+
let target_dir = tmp_path("target");
3838
let target = std::env::var("TARGET").unwrap();
3939

4040
println!("Testing compiler_builtins for {}", target);
4141

4242
// Set up the tiniest Cargo project: An empty no_std library. Just enough to run -Zbuild-std.
43-
let manifest_path = tmp_dir().join("Cargo.toml");
43+
let manifest_path = tmp_path("Cargo.toml");
4444
std::fs::write(&manifest_path, MANIFEST.as_bytes()).unwrap();
45-
std::fs::write(tmp_dir().join("lib.rs"), b"#![no_std]").unwrap();
45+
std::fs::write(tmp_path("lib.rs"), b"#![no_std]").unwrap();
4646

4747
let path = std::env::var("PATH").unwrap();
4848
let rustc = std::env::var("RUSTC").unwrap();

tests/run-make/core-no-oom-handling/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22
// when the no_global_oom_handling feature is turned on.
33
// See https://github.com/rust-lang/rust/pull/110649
44

5-
use run_make_support::{rustc, tmp_dir};
5+
use run_make_support::{rustc, tmp_path};
66

77
fn main() {
88
rustc()
99
.edition("2021")
1010
.arg("-Dwarnings")
1111
.crate_type("rlib")
1212
.input("../../../library/core/src/lib.rs")
13-
.sysroot(tmp_dir().join("fakeroot"))
13+
.sysroot(tmp_path("fakeroot"))
1414
.cfg("no_global_oom_handling")
1515
.run();
1616
}

tests/run-make/cross-lang-lto-riscv-abi/rmake.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
//@ needs-matching-clang
44
//@ needs-llvm-components riscv
55

6-
use run_make_support::{bin_name, clang, llvm_readobj, rustc, tmp_dir};
6+
use run_make_support::{bin_name, clang, llvm_readobj, rustc, tmp_path};
77
use std::{
88
env,
99
path::PathBuf,
@@ -30,11 +30,11 @@ fn check_target(target: &str, clang_target: &str, carch: &str, is_double_float:
3030
.no_stdlib()
3131
.out_exe("riscv-xlto")
3232
.input("cstart.c")
33-
.input(tmp_dir().join("libriscv_xlto.rlib"))
33+
.input(tmp_path("libriscv_xlto.rlib"))
3434
.run();
3535

3636
// Check that the built binary has correct float abi
37-
let executable = tmp_dir().join(bin_name("riscv-xlto"));
37+
let executable = tmp_path(bin_name("riscv-xlto"));
3838
let output = llvm_readobj().input(&executable).file_header().run();
3939
let stdout = String::from_utf8_lossy(&output.stdout);
4040
eprintln!("obj:\n{}", stdout);

tests/run-make/doctests-keep-binaries/rmake.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
// Check that valid binaries are persisted by running them, regardless of whether the
22
// --run or --no-run option is used.
33

4-
use run_make_support::{run, rustc, rustdoc, tmp_dir};
4+
use run_make_support::{run, rustc, rustdoc, tmp_dir, tmp_path};
55
use std::fs::{create_dir, remove_dir_all};
66
use std::path::Path;
77

88
fn setup_test_env<F: FnOnce(&Path, &Path)>(callback: F) {
9-
let out_dir = tmp_dir().join("doctests");
9+
let out_dir = tmp_path("doctests");
1010
create_dir(&out_dir).expect("failed to create doctests folder");
1111
rustc().input("t.rs").crate_type("rlib").run();
12-
callback(&out_dir, &tmp_dir().join("libt.rlib"));
12+
callback(&out_dir, &tmp_path("libt.rlib"));
1313
remove_dir_all(out_dir);
1414
}
1515

@@ -45,7 +45,7 @@ fn main() {
4545
// Behavior with --test-run-directory with relative paths.
4646
setup_test_env(|_out_dir, extern_path| {
4747
let run_dir = "rundir";
48-
let run_dir_path = tmp_dir().join("rundir");
48+
let run_dir_path = tmp_path("rundir");
4949
create_dir(&run_dir_path).expect("failed to create rundir folder");
5050

5151
rustdoc()

tests/run-make/doctests-runtool/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Tests behavior of rustdoc `--runtool`.
22

3-
use run_make_support::{rustc, rustdoc, tmp_dir};
3+
use run_make_support::{rustc, rustdoc, tmp_dir, tmp_path};
44
use std::env::current_dir;
55
use std::fs::{create_dir, remove_dir_all};
66
use std::path::PathBuf;
77

88
fn mkdir(name: &str) -> PathBuf {
9-
let dir = tmp_dir().join(name);
9+
let dir = tmp_path(name);
1010
create_dir(&dir).expect("failed to create doctests folder");
1111
dir
1212
}

tests/run-make/exit-code/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// Test that we exit with the correct exit code for successful / unsuccessful / ICE compilations
22

3-
use run_make_support::{rustc, rustdoc, tmp_dir};
3+
use run_make_support::{rustc, rustdoc, tmp_path};
44

55
fn main() {
66
rustc().arg("success.rs").run();
@@ -15,7 +15,7 @@ fn main() {
1515
.arg("compile-error.rs")
1616
.run_fail_assert_exit_code(101);
1717

18-
rustdoc().arg("success.rs").output(tmp_dir().join("exit-code")).run();
18+
rustdoc().arg("success.rs").output(tmp_path("exit-code")).run();
1919

2020
rustdoc().arg("--invalid-arg-foo").run_fail_assert_exit_code(1);
2121

tests/run-make/issue-107495-archive-permissions/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#[cfg(unix)]
44
extern crate libc;
55

6-
use run_make_support::{aux_build, tmp_dir};
6+
use run_make_support::{aux_build, tmp_path};
77
use std::fs;
88
#[cfg(unix)]
99
use std::os::unix::fs::PermissionsExt;
@@ -16,7 +16,7 @@ fn main() {
1616
}
1717

1818
aux_build().arg("foo.rs").run();
19-
verify(&tmp_dir().join("libfoo.rlib"));
19+
verify(&tmp_path("libfoo.rlib"));
2020
}
2121

2222
fn verify(path: &Path) {

tests/run-make/no-intermediate-extras/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,13 @@
55

66
//@ ignore-cross-compile
77

8-
use run_make_support::{rustc, tmp_dir};
8+
use run_make_support::{rustc, tmp_path};
99
use std::fs;
1010

1111
fn main() {
1212
rustc().crate_type("rlib").arg("--test").input("foo.rs").run();
1313
assert!(
14-
fs::remove_file(tmp_dir().join("foo.bc")).is_err(),
14+
fs::remove_file(tmp_path("foo.bc")).is_err(),
1515
"An unwanted .bc file was created by run-make/no-intermediate-extras."
1616
);
1717
}

tests/run-make/non-unicode-in-incremental-dir/rmake.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
use run_make_support::{rustc, tmp_dir};
1+
use run_make_support::{rustc, tmp_path};
22

33
fn main() {
44
#[cfg(unix)]
55
let non_unicode: &std::ffi::OsStr = std::os::unix::ffi::OsStrExt::from_bytes(&[0xFF]);
66
#[cfg(windows)]
77
let non_unicode: std::ffi::OsString = std::os::windows::ffi::OsStringExt::from_wide(&[0xD800]);
8-
match std::fs::create_dir(tmp_dir().join(&non_unicode)) {
8+
match std::fs::create_dir(tmp_path(&non_unicode)) {
99
// If an error occurs, check if creating a directory with a valid Unicode name would
1010
// succeed.
11-
Err(e) if std::fs::create_dir(tmp_dir().join("valid_unicode")).is_ok() => {
11+
Err(e) if std::fs::create_dir(tmp_path("valid_unicode")).is_ok() => {
1212
// Filesystem doesn't appear support non-Unicode paths.
1313
return;
1414
}
1515
Err(e) => panic!("error creating non-Unicode directory: {e}"),
1616
_ => {}
1717
}
18-
let incr_dir = tmp_dir().join("incr-dir");
18+
let incr_dir = tmp_path("incr-dir");
1919
rustc().input("foo.rs").incremental(&incr_dir).run();
2020
for crate_dir in std::fs::read_dir(&incr_dir).unwrap() {
2121
std::fs::create_dir(crate_dir.unwrap().path().join(&non_unicode)).unwrap();

tests/run-make/print-cfg/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use std::ffi::OsString;
1010
use std::io::BufRead;
1111
use std::iter::FromIterator;
1212

13-
use run_make_support::{rustc, tmp_dir};
13+
use run_make_support::{rustc, tmp_path};
1414

1515
struct PrintCfg {
1616
target: &'static str,
@@ -91,7 +91,7 @@ fn check(PrintCfg { target, includes, disallow }: PrintCfg) {
9191

9292
// --print=cfg=PATH
9393
{
94-
let tmp_path = tmp_dir().join(format!("{target}.cfg"));
94+
let tmp_path = tmp_path(format!("{target}.cfg"));
9595
let mut print_arg = OsString::from("--print=cfg=");
9696
print_arg.push(tmp_path.as_os_str());
9797

tests/run-make/print-to-output/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
44
use std::ffi::OsString;
55

6-
use run_make_support::{rustc, target, tmp_dir};
6+
use run_make_support::{rustc, target, tmp_path};
77

88
struct Option<'a> {
99
target: &'a str,
@@ -46,7 +46,7 @@ fn check(args: Option) {
4646

4747
// --print={option}=PATH
4848
let output = {
49-
let tmp_path = tmp_dir().join(format!("{}.txt", args.option));
49+
let tmp_path = tmp_path(format!("{}.txt", args.option));
5050
let mut print_arg = OsString::from(format!("--print={}=", args.option));
5151
print_arg.push(tmp_path.as_os_str());
5252

tests/run-make/repr128-dwarf/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33

44
use gimli::{AttributeValue, Dwarf, EndianRcSlice, Reader, RunTimeEndian};
55
use object::{Object, ObjectSection};
6-
use run_make_support::{gimli, object, rustc, tmp_dir};
6+
use run_make_support::{gimli, object, rustc, tmp_path};
77
use std::borrow::Cow;
88
use std::collections::HashMap;
99
use std::rc::Rc;
1010

1111
fn main() {
12-
let output = tmp_dir().join("repr128");
12+
let output = tmp_path("repr128");
1313
rustc().input("main.rs").output(&output).arg("-Cdebuginfo=2").run();
1414
// Mach-O uses packed debug info
1515
let dsym_location = output

tests/run-make/reset-codegen-1/rmake.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
//@ ignore-cross-compile
99

10-
use run_make_support::{rustc, tmp_dir};
10+
use run_make_support::{rustc, tmp_path};
1111
use std::fs;
1212

1313
fn compile(output_file: &str, emit: Option<&str>) {
1414
let mut rustc = rustc();
15-
let rustc = rustc.codegen_units(4).output(tmp_dir().join(output_file)).input("foo.rs");
15+
let rustc = rustc.codegen_units(4).output(tmp_path(output_file)).input("foo.rs");
1616
if let Some(emit) = emit {
1717
rustc.emit(emit);
1818
}

tests/run-make/rustdoc-determinism/rmake.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// Assert that the search index is generated deterministically, regardless of the
22
// order that crates are documented in.
33

4-
use run_make_support::{diff, rustdoc, tmp_dir};
4+
use run_make_support::{diff, rustdoc, tmp_path};
55

66
fn main() {
7-
let foo_first = tmp_dir().join("foo_first");
7+
let foo_first = tmp_path("foo_first");
88
rustdoc().input("foo.rs").output(&foo_first).run();
99
rustdoc().input("bar.rs").output(&foo_first).run();
1010

11-
let bar_first = tmp_dir().join("bar_first");
11+
let bar_first = tmp_path("bar_first");
1212
rustdoc().input("bar.rs").output(&bar_first).run();
1313
rustdoc().input("foo.rs").output(&bar_first).run();
1414

tests/run-make/rustdoc-map-file/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use run_make_support::{python_command, rustdoc, tmp_dir};
22

33
fn main() {
4-
let out_dir = tmp_dir().join("out");
4+
let out_dir = tmp_path("out");
55
rustdoc()
66
.input("foo.rs")
77
.arg("-Zunstable-options")
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
// Checks that if the output folder doesn't exist, rustdoc will create it.
22

3-
use run_make_support::{rustdoc, tmp_dir};
3+
use run_make_support::{rustdoc, tmp_path};
44

55
fn main() {
6-
let out_dir = tmp_dir().join("foo/bar/doc");
6+
let out_dir = tmp_path("foo/bar/doc");
77
rustdoc().input("foo.rs").output(&out_dir).run();
88
assert!(out_dir.exists());
99
}

tests/run-make/rustdoc-scrape-examples-remap/scrape.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
use run_make_support::{htmldocck, rustc, rustdoc, source_path, tmp_dir};
1+
use run_make_support::{htmldocck, rustc, rustdoc, source_path, tmp_dir, tmp_path};
22
use std::fs::read_dir;
33
use std::path::Path;
44

55
pub fn scrape(extra_args: &[&str]) {
66
let lib_dir = tmp_dir();
7-
let out_dir = tmp_dir().join("rustdoc");
7+
let out_dir = tmp_path("rustdoc");
88
let crate_name = "foobar";
99
let deps = read_dir("examples")
1010
.unwrap()

0 commit comments

Comments
 (0)