Skip to content

Commit 55825a4

Browse files
authored
Merge pull request #22010 from erfanio/rustfmt-fix
Fix rustfmt relative custom command
2 parents 9eb97ea + 342d9ed commit 55825a4

File tree

1 file changed

+1
-2
lines changed

1 file changed

+1
-2
lines changed

crates/rust-analyzer/src/handlers/request.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2442,8 +2442,7 @@ fn run_rustfmt(
24422442
}
24432443
RustfmtConfig::CustomCommand { command, args } => {
24442444
let cmd = Utf8PathBuf::from(&command);
2445-
let target_spec =
2446-
crates.first().and_then(|&crate_id| snap.target_spec_for_file(file_id, crate_id));
2445+
let target_spec = TargetSpec::for_file(snap, file_id).ok().flatten();
24472446
let extra_env = snap.config.extra_env(source_root_id);
24482447
let mut cmd = match target_spec {
24492448
Some(TargetSpec::Cargo(_)) => {

0 commit comments

Comments
 (0)