Skip to content

Commit b50af95

Browse files
authored
fix: Canonicalize flycheck output path
1 parent 5f3539a commit b50af95

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

crates/rust-analyzer/src/flycheck.rs

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,11 +445,19 @@ impl FlycheckActor {
445445
let target_dir = target_dir.as_deref().or(ws_target_dir);
446446

447447
Some(
448-
target_dir
449-
.unwrap_or(
448+
// As `CommandHandle::spawn`'s working directory is
449+
// rust-analyzer's working directory, which might be different
450+
// from the flycheck's working directory, we should canonicalize
451+
// the output directory, otherwise we might write it into the
452+
// wrong target dir.
453+
// If `target_dir` is an absolute path, it will replace
454+
// `self.root` and that's an intended behavior.
455+
self.root
456+
.join(target_dir.unwrap_or(
450457
Utf8Path::new("target").join("rust-analyzer").as_path(),
451-
)
452-
.join(format!("flycheck{}", self.id)),
458+
))
459+
.join(format!("flycheck{}", self.id))
460+
.into(),
453461
)
454462
}
455463
_ => None,

0 commit comments

Comments
 (0)