Skip to content

Commit

Permalink
Improve target method API in run-make-support
Browse files Browse the repository at this point in the history
  • Loading branch information
GuillaumeGomez committed Jul 1, 2024
1 parent b5b97dc commit fcfac05
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/tools/run-make-support/src/rustc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,8 @@ impl Rustc {
}

/// Specify the target triple, or a path to a custom target json spec file.
pub fn target(&mut self, target: &str) -> &mut Self {
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
let target = target.as_ref();
self.cmd.arg(format!("--target={target}"));
self
}
Expand Down
3 changes: 2 additions & 1 deletion src/tools/run-make-support/src/rustdoc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ impl Rustdoc {
}

/// Specify the target triple, or a path to a custom target json spec file.
pub fn target(&mut self, target: &str) -> &mut Self {
pub fn target<S: AsRef<str>>(&mut self, target: S) -> &mut Self {
let target = target.as_ref();
self.cmd.arg(format!("--target={target}"));
self
}
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/comment-section/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ fn main() {
.stdin("fn main() {}")
.emit("link,obj")
.arg("-Csave-temps")
.target(&target)
.target(target)
.run();

// Check linked output has a `.comment` section with the expected content.
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/inaccessible-temp-dir/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fn main() {
// Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one,
// so that it can't create `tmp`.
rustc()
.target(&target())
.target(target())
.input("program.rs")
.arg("-Ztemps-dir=inaccessible/tmp")
.run_fail()
Expand Down
2 changes: 1 addition & 1 deletion tests/run-make/static-pie/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ fn test(compiler: &str) {

rustc()
.input("test-aslr.rs")
.target(&target())
.target(target())
.linker(compiler)
.arg("-Clinker-flavor=gcc")
.arg("-Ctarget-feature=+crt-static")
Expand Down

0 comments on commit fcfac05

Please sign in to comment.