aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_cargo_watch
diff options
context:
space:
mode:
authorEmil Lauridsen <[email protected]>2020-01-28 13:48:50 +0000
committerEmil Lauridsen <[email protected]>2020-01-28 13:48:50 +0000
commit35025f097532b3f927f802a4130f7cd8a854f134 (patch)
tree5b23b68c7f0d50aa9e4117922bbbdc105e9fbd8c /crates/ra_cargo_watch
parent912776fd9547d1d28b4cba7e4a41e5391fc12c21 (diff)
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.
Diffstat (limited to 'crates/ra_cargo_watch')
-rw-r--r--crates/ra_cargo_watch/src/lib.rs6
1 files changed, 4 insertions, 2 deletions
diff --git a/crates/ra_cargo_watch/src/lib.rs b/crates/ra_cargo_watch/src/lib.rs
index e7b700c10..1a35151ee 100644
--- a/crates/ra_cargo_watch/src/lib.rs
+++ b/crates/ra_cargo_watch/src/lib.rs
@@ -216,8 +216,10 @@ impl CheckWatcherThread {
216 self.last_update_req.take(); 216 self.last_update_req.take();
217 task_send.send(CheckTask::ClearDiagnostics).unwrap(); 217 task_send.send(CheckTask::ClearDiagnostics).unwrap();
218 218
219 // By replacing the watcher, we drop the previous one which 219 // Replace with a dummy watcher first so we drop the original and wait for completion
220 // causes it to shut down automatically. 220 std::mem::replace(&mut self.watcher, WatchThread::dummy());
221
222 // Then create the actual new watcher
221 self.watcher = WatchThread::new(&self.options, &self.workspace_root); 223 self.watcher = WatchThread::new(&self.options, &self.workspace_root);
222 } 224 }
223 } 225 }