From f75feb67244c279e75a4e8c9996a72eed729d321 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 17 Apr 2019 11:47:29 +0300 Subject: cleanup cancellation Now that we explicitelly exit the reading loop on exit notification, we can assume that the sender is always alive --- crates/ra_lsp_server/tests/heavy_tests/support.rs | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'crates/ra_lsp_server/tests/heavy_tests') diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs index b07882700..d68182174 100644 --- a/crates/ra_lsp_server/tests/heavy_tests/support.rs +++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs @@ -77,7 +77,7 @@ pub struct Server { req_id: Cell, messages: RefCell>, dir: TempDir, - worker: Option>, + worker: Worker, } impl Server { @@ -99,12 +99,7 @@ impl Server { .unwrap() }, ); - let res = Server { - req_id: Cell::new(1), - dir, - messages: Default::default(), - worker: Some(worker), - }; + let res = Server { req_id: Cell::new(1), dir, messages: Default::default(), worker }; for (path, text) in files { res.send_notification(RawNotification::new::( @@ -157,7 +152,7 @@ impl Server { } fn send_request_(&self, r: RawRequest) -> Value { let id = r.id; - self.worker.as_ref().unwrap().sender().send(RawMessage::Request(r)).unwrap(); + self.worker.sender().send(RawMessage::Request(r)).unwrap(); while let Some(msg) = self.recv() { match msg { RawMessage::Request(req) => panic!("unexpected request: {:?}", req), @@ -197,13 +192,13 @@ impl Server { } } fn recv(&self) -> Option { - recv_timeout(&self.worker.as_ref().unwrap().receiver()).map(|msg| { + recv_timeout(&self.worker.receiver()).map(|msg| { self.messages.borrow_mut().push(msg.clone()); msg }) } fn send_notification(&self, not: RawNotification) { - self.worker.as_ref().unwrap().sender().send(RawMessage::Notification(not)).unwrap(); + self.worker.sender().send(RawMessage::Notification(not)).unwrap(); } pub fn path(&self) -> &Path { -- cgit v1.2.3