We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
rustfmt
cargo-fmt
1 parent bf5f0ea commit 1443bbaCopy full SHA for 1443bba
src/cargo-fmt/main.rs
@@ -6,7 +6,6 @@
6
use std::cmp::Ordering;
7
use std::collections::{BTreeMap, BTreeSet};
8
use std::env;
9
-use std::ffi::OsStr;
10
use std::fs;
11
use std::hash::{Hash, Hasher};
12
use std::io::{self, Write};
@@ -151,11 +150,13 @@ fn execute() -> i32 {
151
150
}
152
153
fn rustfmt_command() -> Command {
154
- let rustfmt_var = env::var_os("RUSTFMT");
155
- let rustfmt = match &rustfmt_var {
156
- Some(rustfmt) => rustfmt,
157
- None => OsStr::new("rustfmt"),
+ let rustfmt = match env::var_os("RUSTFMT") {
+ Some(rustfmt) => PathBuf::from(rustfmt),
+ None => env::current_exe()
+ .expect("current executable path invalid")
+ .with_file_name("rustfmt"),
158
};
159
+
160
Command::new(rustfmt)
161
162
0 commit comments