Skip to content

Commit

Permalink
update errors
Browse files Browse the repository at this point in the history
  • Loading branch information
benluiwj committed Sep 29, 2024
1 parent f155d6d commit 3baa49d
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions check_diff/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ use std::io;
use std::path::{Path, PathBuf};
use std::process::{Command, Output};
use std::str::Utf8Error;
use std::string::FromUtf8Error;
use tracing::info;

pub enum CheckDiffError {
Expand Down Expand Up @@ -34,9 +33,9 @@ impl From<GitError> for CheckDiffError {
}
}

impl From<FromUtf8Error> for CheckDiffError {
fn from(error: FromUtf8Error) -> Self {
CheckDiffError::FailedUtf8(error.utf8_error())
impl From<Utf8Error> for CheckDiffError {
fn from(error: Utf8Error) -> Self {
CheckDiffError::FailedUtf8(error)
}
}

Expand Down Expand Up @@ -87,8 +86,7 @@ impl RustfmtRunner {
));
};

let binding = String::from_utf8(command.stdout)?;
let binary_version = binding.trim();
let binary_version = std::str::from_utf8(&command.stdout)?.trim_end();
return Ok(binary_version.to_string());
}
}
Expand Down Expand Up @@ -196,7 +194,7 @@ pub fn get_ld_lib_path() -> Result<String, CheckDiffError> {
return Err(CheckDiffError::FailedCommand("Error getting sysroot"));
};

let sysroot = String::from_utf8(command.stdout)?;
let sysroot = std::str::from_utf8(&command.stdout)?.trim_end();

let ld_lib_path = format!("{}/lib", sysroot.trim_end());
return Ok(ld_lib_path);
Expand All @@ -209,9 +207,8 @@ pub fn get_cargo_version() -> Result<String, CheckDiffError> {
));
};

let cargo_version = String::from_utf8(command.stdout)?;

return Ok(cargo_version);
let cargo_version = std::str::from_utf8(&command.stdout)?.trim_end();
return Ok(cargo_version.to_string());
}

/// Obtains the ld_lib path and then builds rustfmt from source
Expand Down

0 comments on commit 3baa49d

Please sign in to comment.