about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume.gomez@huawei.com>2024-07-01 10:55:43 +0200
committerGuillaume Gomez <guillaume.gomez@huawei.com>2024-07-01 10:55:57 +0200
commitfcfac05657acf387392f853904c917ac06c082c5 (patch)
tree445ddb2010f2f3fec4a6d500102a2d743e7917cd
parentb5b97dccaeb764c7dc0e7877941808acabb1cc8c (diff)
Improve `target` method API in `run-make-support`
-rw-r--r--src/tools/run-make-support/src/rustc.rs3
-rw-r--r--src/tools/run-make-support/src/rustdoc.rs3
-rw-r--r--tests/run-make/comment-section/rmake.rs2
-rw-r--r--tests/run-make/inaccessible-temp-dir/rmake.rs2
-rw-r--r--tests/run-make/static-pie/rmake.rs2
5 files changed, 7 insertions, 5 deletions
diff --git a/src/tools/run-make-support/src/rustc.rs b/src/tools/run-make-support/src/rustc.rs
index df843d74fc9..3f23c1b8f9e 100644
--- a/src/tools/run-make-support/src/rustc.rs
+++ b/src/tools/run-make-support/src/rustc.rs
@@ -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
     }
diff --git a/src/tools/run-make-support/src/rustdoc.rs b/src/tools/run-make-support/src/rustdoc.rs
index fb00427b1c1..2be962ad888 100644
--- a/src/tools/run-make-support/src/rustdoc.rs
+++ b/src/tools/run-make-support/src/rustdoc.rs
@@ -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
     }
diff --git a/tests/run-make/comment-section/rmake.rs b/tests/run-make/comment-section/rmake.rs
index 41df04da7a5..188c6dcb25d 100644
--- a/tests/run-make/comment-section/rmake.rs
+++ b/tests/run-make/comment-section/rmake.rs
@@ -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.
diff --git a/tests/run-make/inaccessible-temp-dir/rmake.rs b/tests/run-make/inaccessible-temp-dir/rmake.rs
index c6bfae4cc01..6b3e9e0b29e 100644
--- a/tests/run-make/inaccessible-temp-dir/rmake.rs
+++ b/tests/run-make/inaccessible-temp-dir/rmake.rs
@@ -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()
diff --git a/tests/run-make/static-pie/rmake.rs b/tests/run-make/static-pie/rmake.rs
index 77c5e253bc0..6a92f92328e 100644
--- a/tests/run-make/static-pie/rmake.rs
+++ b/tests/run-make/static-pie/rmake.rs
@@ -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")