Improve target method API in run-make-support · rust-lang/rust@fcfac05 (original) (raw)

File tree

5 files changed

lines changed

5 files changed

lines changed

Original file line number Diff line number Diff line change
@@ -201,7 +201,8 @@ impl Rustc {
201 201 }
202 202
203 203 /// 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();
205 206 self.cmd.arg(format!("--target={target}"));
206 207 self
207 208 }
Original file line number Diff line number Diff line change
@@ -104,7 +104,8 @@ impl Rustdoc {
104 104 }
105 105
106 106 /// 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();
108 109 self.cmd.arg(format!("--target={target}"));
109 110 self
110 111 }
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ fn main() {
21 21 .stdin("fn main() {}")
22 22 .emit("link,obj")
23 23 .arg("-Csave-temps")
24 -.target(&target)
24 +.target(target)
25 25 .run();
26 26
27 27 // Check linked output has a `.comment` section with the expected content.
Original file line number Diff line number Diff line change
@@ -28,7 +28,7 @@ fn main() {
28 28 // Run rustc with `-Z temps-dir` set to a directory *inside* the inaccessible one,
29 29 // so that it can't create `tmp`.
30 30 rustc()
31 -.target(&target())
31 +.target(target())
32 32 .input("program.rs")
33 33 .arg("-Ztemps-dir=inaccessible/tmp")
34 34 .run_fail()
Original file line number Diff line number Diff line change
@@ -51,7 +51,7 @@ fn test(compiler: &str) {
51 51
52 52 rustc()
53 53 .input("test-aslr.rs")
54 -.target(&target())
54 +.target(target())
55 55 .linker(compiler)
56 56 .arg("-Clinker-flavor=gcc")
57 57 .arg("-Ctarget-feature=+crt-static")