Improve `target` method API in `run-make-support`

This commit is contained in:
Guillaume Gomez 2024-07-01 10:55:43 +02:00
parent b5b97dccae
commit fcfac05657
5 changed files with 7 additions and 5 deletions

View File

@ -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
}

View File

@ -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
}

View File

@ -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.

View File

@ -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()

View File

@ -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")