Skip to content

Commit fcfac05

Browse files
Improve target method API in run-make-support
1 parent b5b97dc commit fcfac05

File tree

5 files changed

+7
-5
lines changed

5 files changed

+7
-5
lines changed

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,8 @@ impl Rustc {
201201
}
202202

203203
/// Specify the target triple, or a path to a custom target json spec file.
204-
pub fn target(&mut self, target: &str) -> &mut Self {
204+
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
205+
let target = target.as_ref();
205206
self.cmd.arg(format!("--target={target}"));
206207
self
207208
}

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

+2-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ impl Rustdoc {
104104
}
105105

106106
/// Specify the target triple, or a path to a custom target json spec file.
107-
pub fn target(&mut self, target: &str) -> &mut Self {
107+
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
108+
let target = target.as_ref();
108109
self.cmd.arg(format!("--target={target}"));
109110
self
110111
}

tests/run-make/comment-section/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ fn main() {
2121
.stdin("fn main() {}")
2222
.emit("link,obj")
2323
.arg("-Csave-temps")
24-
.target(&target)
24+
.target(target)
2525
.run();
2626

2727
// Check linked output has a `.comment` section with the expected content.

tests/run-make/inaccessible-temp-dir/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fn main() {
2828
// Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one,
2929
// so that it can't create `tmp`.
3030
rustc()
31-
.target(&target())
31+
.target(target())
3232
.input("program.rs")
3333
.arg("-Ztemps-dir=inaccessible/tmp")
3434
.run_fail()

tests/run-make/static-pie/rmake.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ fn test(compiler: &str) {
5151

5252
rustc()
5353
.input("test-aslr.rs")
54-
.target(&target())
54+
.target(target())
5555
.linker(compiler)
5656
.arg("-Clinker-flavor=gcc")
5757
.arg("-Ctarget-feature=+crt-static")

0 commit comments

Comments
 (0)