File tree Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Expand file tree Collapse file tree 1 file changed +12
-4
lines changed Original file line number Diff line number Diff 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 ,
You can’t perform that action at this time.
0 commit comments