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

Lines changed: 6 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 7 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 4 additions & 4 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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) {

0 commit comments

Comments
 (0)