diff --git a/check_diff/src/lib.rs b/check_diff/src/lib.rs index 292d48b2d15..3782d393f60 100644 --- a/check_diff/src/lib.rs +++ b/check_diff/src/lib.rs @@ -75,6 +75,22 @@ impl RustfmtRunner { .args(args) .output() } + + fn get_binary_version(&self) -> Result { + let Ok(command) = Command::new(&self.binary_path) + .env("LD_LIB_PATH", &self.ld_library_path) + .args(["--version"]) + .output() + else { + return Err(CheckDiffError::FailedBinaryVersioning( + self.binary_path.to_path_buf(), + )); + }; + + let binding = String::from_utf8(command.stdout)?; + let binary_version = binding.trim(); + return Ok(binary_version.to_string()); + } } /// Clone a git repository @@ -198,23 +214,9 @@ pub fn get_cargo_version() -> Result { return Ok(cargo_version); } -pub fn get_binary_version(binary: &Path, ld_lib_path: &String) -> Result { - let Ok(command) = Command::new(binary) - .env("LD_LIB_PATH", ld_lib_path) - .args(["--version"]) - .output() - else { - return Err(CheckDiffError::FailedBinaryVersioning(binary.to_path_buf())); - }; - - let binary_version = String::from_utf8(command.stdout)?; - - return Ok(binary_version); -} - /// Obtains the ld_lib path and then builds rustfmt from source /// If that operation succeeds, the source is then copied to the output path specified -pub fn build_rustfmt_from_src(binary_path: &Path) -> Result { +pub fn build_rustfmt_from_src(binary_path: PathBuf) -> Result { //Because we're building standalone binaries we need to set `LD_LIBRARY_PATH` so each // binary can find it's runtime dependencies. // See https://github.com/rust-lang/rustfmt/issues/5675 @@ -235,7 +237,7 @@ pub fn build_rustfmt_from_src(binary_path: &Path) -> Result