Skip to content

Commit

Permalink
run-make: make arg take AsRef<OsStr> instead of str
Browse files Browse the repository at this point in the history
  • Loading branch information
5225225 committed Apr 9, 2024
1 parent 65df93b commit de79a6c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
11 changes: 3 additions & 8 deletions src/tools/run-make-support/src/rustdoc.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::env;
use std::ffi::OsStr;
use std::path::Path;
use std::process::{Command, Output};

Expand Down Expand Up @@ -58,18 +59,12 @@ impl Rustdoc {
self
}

/// Fallback argument provider. Consider adding meaningfully named methods instead of using
/// this method.
pub fn arg(&mut self, arg: &str) -> &mut Self {
/// Generic command argument provider. Use `.arg("-Zname")` over `.arg("-Z").arg("arg")`.
pub fn arg<S: AsRef<OsStr>>(&mut self, arg: S) -> &mut Self {
self.cmd.arg(arg);
self
}

pub fn arg_path<P: AsRef<Path>>(&mut self, path: P) -> &mut Self {
self.cmd.arg(path.as_ref());
self
}

/// Run the build `rustdoc` command and assert that the run is successful.
#[track_caller]
pub fn run(&mut self) -> Output {
Expand Down
3 changes: 2 additions & 1 deletion tests/run-make/exit-code/rmake.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ fn main() {

rustdoc()
.arg("success.rs")
.arg("-o").arg_path(tmp_dir().join("exit-code"))
.arg("-o")
.arg(tmp_dir().join("exit-code"))
.run();

rustdoc()
Expand Down

0 comments on commit de79a6c

Please sign in to comment.