Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 11 additions & 8 deletions clippy_dev/src/fmt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -307,16 +307,19 @@ fn run_rustfmt(context: &FmtContext) -> Result<(), Error> {

// the "main" function of cargo dev fmt
pub fn run(check: bool, verbose: bool) {
let output = Command::new("rustup")
let result = Command::new("rustup")
.args(["which", "rustfmt"])
.stderr(Stdio::inherit())
.output()
.expect("error running `rustup which rustfmt`");
if !output.status.success() {
eprintln!("`rustup which rustfmt` did not execute successfully");
process::exit(1);
}
let mut rustfmt_path = String::from_utf8(output.stdout).expect("invalid rustfmt path");
.output();

let mut rustfmt_path = if let Ok(output) = result
&& output.status.success()
{
String::from_utf8(output.stdout).expect("invalid rustfmt path")
} else {
String::from("rustfmt")
};

rustfmt_path.truncate(rustfmt_path.trim_end().len());

let context = FmtContext {
Expand Down