Skip to content

Commit 35025f0

Browse files
committed
Modify ordering of drops in check watcher to only ever have one cargo
Due to the way drops are ordered when assigning to a mutable variable we were launching a new cargo sub-process before letting the old one quite. By explicitly replacing the original watcher with a dummy first, we ensure it is dropped and the process is completed, before we start the new process.
1 parent 912776f commit 35025f0

File tree

1 file changed

+4
-2
lines changed
  • crates/ra_cargo_watch/src

1 file changed

+4
-2
lines changed

crates/ra_cargo_watch/src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,10 @@ impl CheckWatcherThread {
216216
self.last_update_req.take();
217217
task_send.send(CheckTask::ClearDiagnostics).unwrap();
218218

219-
// By replacing the watcher, we drop the previous one which
220-
// causes it to shut down automatically.
219+
// Replace with a dummy watcher first so we drop the original and wait for completion
220+
std::mem::replace(&mut self.watcher, WatchThread::dummy());
221+
222+
// Then create the actual new watcher
221223
self.watcher = WatchThread::new(&self.options, &self.workspace_root);
222224
}
223225
}

0 commit comments

Comments
 (0)