aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2018-12-30 20:24:48 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2018-12-30 20:24:48 +0000
commit45e3de8eed878afa1066b61fa27f7625bf57b1e6 (patch)
treeb53c11bcb1e117701fef86853eaf9a1675ae105f
parentbb604f0a255078a6b30555a5535ee1d277237e38 (diff)
parentc2c10b9014549e9c0783fb13dc202dfab6e6fd0a (diff)
Merge #377
377: update crossbeam r=matklad a=matklad Co-authored-by: Aleksey Kladov <[email protected]>
-rw-r--r--Cargo.lock39
-rw-r--r--crates/gen_lsp_server/Cargo.toml2
-rw-r--r--crates/gen_lsp_server/src/lib.rs10
-rw-r--r--crates/gen_lsp_server/src/stdio.rs10
-rw-r--r--crates/ra_lsp_server/Cargo.toml2
-rw-r--r--crates/ra_lsp_server/src/main_loop.rs48
-rw-r--r--crates/ra_lsp_server/src/project_model.rs4
-rw-r--r--crates/ra_lsp_server/tests/heavy_tests/support.rs13
-rw-r--r--crates/ra_vfs/Cargo.toml2
-rw-r--r--crates/ra_vfs/src/io.rs4
-rw-r--r--crates/ra_vfs/src/lib.rs2
-rw-r--r--crates/thread_worker/Cargo.toml2
-rw-r--r--crates/thread_worker/src/lib.rs6
13 files changed, 70 insertions, 74 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 8e962d352..0d63ec639 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -166,13 +166,12 @@ dependencies = [
166 166
167[[package]] 167[[package]]
168name = "crossbeam-channel" 168name = "crossbeam-channel"
169version = "0.2.6" 169version = "0.3.6"
170source = "registry+https://github.com/rust-lang/crates.io-index" 170source = "registry+https://github.com/rust-lang/crates.io-index"
171dependencies = [ 171dependencies = [
172 "crossbeam-epoch 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)", 172 "crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
173 "crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)", 173 "parking_lot 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
174 "parking_lot 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", 174 "rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)",
175 "rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)",
176 "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)", 175 "smallvec 0.6.7 (registry+https://github.com/rust-lang/crates.io-index)",
177] 176]
178 177
@@ -200,19 +199,6 @@ dependencies = [
200] 199]
201 200
202[[package]] 201[[package]]
203name = "crossbeam-epoch"
204version = "0.6.1"
205source = "registry+https://github.com/rust-lang/crates.io-index"
206dependencies = [
207 "arrayvec 0.4.10 (registry+https://github.com/rust-lang/crates.io-index)",
208 "cfg-if 0.1.6 (registry+https://github.com/rust-lang/crates.io-index)",
209 "crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)",
210 "lazy_static 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)",
211 "memoffset 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
212 "scopeguard 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
213]
214
215[[package]]
216name = "crossbeam-utils" 202name = "crossbeam-utils"
217version = "0.2.2" 203version = "0.2.2"
218source = "registry+https://github.com/rust-lang/crates.io-index" 204source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -222,11 +208,6 @@ dependencies = [
222 208
223[[package]] 209[[package]]
224name = "crossbeam-utils" 210name = "crossbeam-utils"
225version = "0.5.0"
226source = "registry+https://github.com/rust-lang/crates.io-index"
227
228[[package]]
229name = "crossbeam-utils"
230version = "0.6.3" 211version = "0.6.3"
231source = "registry+https://github.com/rust-lang/crates.io-index" 212source = "registry+https://github.com/rust-lang/crates.io-index"
232dependencies = [ 213dependencies = [
@@ -355,7 +336,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
355name = "gen_lsp_server" 336name = "gen_lsp_server"
356version = "0.1.0" 337version = "0.1.0"
357dependencies = [ 338dependencies = [
358 "crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", 339 "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
359 "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 340 "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
360 "languageserver-types 0.53.1 (registry+https://github.com/rust-lang/crates.io-index)", 341 "languageserver-types 0.53.1 (registry+https://github.com/rust-lang/crates.io-index)",
361 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 342 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -764,7 +745,7 @@ name = "ra_lsp_server"
764version = "0.1.0" 745version = "0.1.0"
765dependencies = [ 746dependencies = [
766 "cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)", 747 "cargo_metadata 0.6.4 (registry+https://github.com/rust-lang/crates.io-index)",
767 "crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", 748 "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
768 "drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", 749 "drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
769 "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 750 "failure 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
770 "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)", 751 "failure_derive 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -824,7 +805,7 @@ dependencies = [
824name = "ra_vfs" 805name = "ra_vfs"
825version = "0.1.0" 806version = "0.1.0"
826dependencies = [ 807dependencies = [
827 "crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", 808 "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
828 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 809 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
829 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", 810 "relative-path 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
830 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", 811 "rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)",
@@ -1308,7 +1289,7 @@ dependencies = [
1308name = "thread_worker" 1289name = "thread_worker"
1309version = "0.1.0" 1290version = "0.1.0"
1310dependencies = [ 1291dependencies = [
1311 "crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)", 1292 "crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
1312 "drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", 1293 "drop_bomb 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
1313 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", 1294 "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)",
1314] 1295]
@@ -1543,12 +1524,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
1543"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878" 1524"checksum chrono 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)" = "45912881121cb26fad7c38c17ba7daa18764771836b34fab7d3fbd93ed633878"
1544"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e" 1525"checksum clap 2.32.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b957d88f4b6a63b9d70d5f454ac8011819c6efa7727858f458ab71c756ce2d3e"
1545"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f" 1526"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
1546"checksum crossbeam-channel 0.2.6 (registry+https://github.com/rust-lang/crates.io-index)" = "7b85741761b7f160bc5e7e0c14986ef685b7f8bf9b7ad081c60c604bb4649827" 1527"checksum crossbeam-channel 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "137bc235f622ffaa0428e3854e24acb53291fc0b3ff6fb2cb75a8be6fb02f06b"
1547"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3" 1528"checksum crossbeam-deque 0.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f739f8c5363aca78cfb059edf753d8f0d36908c348f3d8d1503f03d8b75d9cf3"
1548"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150" 1529"checksum crossbeam-epoch 0.3.1 (registry+https://github.com/rust-lang/crates.io-index)" = "927121f5407de9956180ff5e936fe3cf4324279280001cd56b669d28ee7e9150"
1549"checksum crossbeam-epoch 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "2449aaa4ec7ef96e5fb24db16024b935df718e9ae1cec0a1e68feeca2efca7b8"
1550"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9" 1530"checksum crossbeam-utils 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "2760899e32a1d58d5abb31129f8fae5de75220bc2176e77ff7c627ae45c918d9"
1551"checksum crossbeam-utils 0.5.0 (registry+https://github.com/rust-lang/crates.io-index)" = "677d453a17e8bd2b913fa38e8b9cf04bcdbb5be790aa294f2389661d72036015"
1552"checksum crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "41ee4864f4797060e52044376f7d107429ce1fb43460021b126424b7180ee21a" 1531"checksum crossbeam-utils 0.6.3 (registry+https://github.com/rust-lang/crates.io-index)" = "41ee4864f4797060e52044376f7d107429ce1fb43460021b126424b7180ee21a"
1553"checksum derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6ca414e896ae072546f4d789f452daaecf60ddee4c9df5dc6d5936d769e3d87c" 1532"checksum derive-new 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6ca414e896ae072546f4d789f452daaecf60ddee4c9df5dc6d5936d769e3d87c"
1554"checksum deunicode 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690" 1533"checksum deunicode 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "850878694b7933ca4c9569d30a34b55031b9b139ee1fc7b94a527c4ef960d690"
diff --git a/crates/gen_lsp_server/Cargo.toml b/crates/gen_lsp_server/Cargo.toml
index afeeb1513..2aee4ea16 100644
--- a/crates/gen_lsp_server/Cargo.toml
+++ b/crates/gen_lsp_server/Cargo.toml
@@ -13,4 +13,4 @@ log = "0.4.3"
13failure = "0.1.2" 13failure = "0.1.2"
14serde_json = "1.0.24" 14serde_json = "1.0.24"
15serde = { version = "1.0.83", features = ["derive"] } 15serde = { version = "1.0.83", features = ["derive"] }
16crossbeam-channel = "0.2.4" 16crossbeam-channel = "0.3.5"
diff --git a/crates/gen_lsp_server/src/lib.rs b/crates/gen_lsp_server/src/lib.rs
index 8779fbf0f..b20652928 100644
--- a/crates/gen_lsp_server/src/lib.rs
+++ b/crates/gen_lsp_server/src/lib.rs
@@ -95,7 +95,7 @@ pub fn run_server(
95 server(params, &receiver, &sender)?; 95 server(params, &receiver, &sender)?;
96 log::info!("lsp server waiting for exit notification"); 96 log::info!("lsp server waiting for exit notification");
97 match receiver.recv() { 97 match receiver.recv() {
98 Some(RawMessage::Notification(n)) => n 98 Ok(RawMessage::Notification(n)) => n
99 .cast::<Exit>() 99 .cast::<Exit>()
100 .map_err(|n| format_err!("unexpected notification during shutdown: {:?}", n))?, 100 .map_err(|n| format_err!("unexpected notification during shutdown: {:?}", n))?,
101 m => bail!("unexpected message during shutdown: {:?}", m), 101 m => bail!("unexpected message during shutdown: {:?}", m),
@@ -109,7 +109,7 @@ pub fn handle_shutdown(req: RawRequest, sender: &Sender<RawMessage>) -> Option<R
109 match req.cast::<Shutdown>() { 109 match req.cast::<Shutdown>() {
110 Ok((id, ())) => { 110 Ok((id, ())) => {
111 let resp = RawResponse::ok::<Shutdown>(id, &()); 111 let resp = RawResponse::ok::<Shutdown>(id, &());
112 sender.send(RawMessage::Response(resp)); 112 let _ = sender.send(RawMessage::Response(resp));
113 None 113 None
114 } 114 }
115 Err(req) => Some(req), 115 Err(req) => Some(req),
@@ -122,16 +122,16 @@ fn initialize(
122 caps: ServerCapabilities, 122 caps: ServerCapabilities,
123) -> Result<InitializeParams> { 123) -> Result<InitializeParams> {
124 let (id, params) = match receiver.recv() { 124 let (id, params) = match receiver.recv() {
125 Some(RawMessage::Request(req)) => match req.cast::<Initialize>() { 125 Ok(RawMessage::Request(req)) => match req.cast::<Initialize>() {
126 Err(req) => bail!("expected initialize request, got {:?}", req), 126 Err(req) => bail!("expected initialize request, got {:?}", req),
127 Ok(req) => req, 127 Ok(req) => req,
128 }, 128 },
129 msg => bail!("expected initialize request, got {:?}", msg), 129 msg => bail!("expected initialize request, got {:?}", msg),
130 }; 130 };
131 let resp = RawResponse::ok::<Initialize>(id, &InitializeResult { capabilities: caps }); 131 let resp = RawResponse::ok::<Initialize>(id, &InitializeResult { capabilities: caps });
132 sender.send(RawMessage::Response(resp)); 132 sender.send(RawMessage::Response(resp)).unwrap();
133 match receiver.recv() { 133 match receiver.recv() {
134 Some(RawMessage::Notification(n)) => { 134 Ok(RawMessage::Notification(n)) => {
135 n.cast::<Initialized>() 135 n.cast::<Initialized>()
136 .map_err(|_| format_err!("expected initialized notification"))?; 136 .map_err(|_| format_err!("expected initialized notification"))?;
137 } 137 }
diff --git a/crates/gen_lsp_server/src/stdio.rs b/crates/gen_lsp_server/src/stdio.rs
index 35d8e46d0..5c8e33854 100644
--- a/crates/gen_lsp_server/src/stdio.rs
+++ b/crates/gen_lsp_server/src/stdio.rs
@@ -9,11 +9,13 @@ use failure::bail;
9use crate::{RawMessage, Result}; 9use crate::{RawMessage, Result};
10 10
11pub fn stdio_transport() -> (Receiver<RawMessage>, Sender<RawMessage>, Threads) { 11pub fn stdio_transport() -> (Receiver<RawMessage>, Sender<RawMessage>, Threads) {
12 let (writer_sender, mut writer_receiver) = bounded::<RawMessage>(16); 12 let (writer_sender, writer_receiver) = bounded::<RawMessage>(16);
13 let writer = thread::spawn(move || { 13 let writer = thread::spawn(move || {
14 let stdout = stdout(); 14 let stdout = stdout();
15 let mut stdout = stdout.lock(); 15 let mut stdout = stdout.lock();
16 writer_receiver.try_for_each(|it| it.write(&mut stdout))?; 16 writer_receiver
17 .into_iter()
18 .try_for_each(|it| it.write(&mut stdout))?;
17 Ok(()) 19 Ok(())
18 }); 20 });
19 let (reader_sender, reader_receiver) = bounded::<RawMessage>(16); 21 let (reader_sender, reader_receiver) = bounded::<RawMessage>(16);
@@ -21,7 +23,9 @@ pub fn stdio_transport() -> (Receiver<RawMessage>, Sender<RawMessage>, Threads)
21 let stdin = stdin(); 23 let stdin = stdin();
22 let mut stdin = stdin.lock(); 24 let mut stdin = stdin.lock();
23 while let Some(msg) = RawMessage::read(&mut stdin)? { 25 while let Some(msg) = RawMessage::read(&mut stdin)? {
24 reader_sender.send(msg); 26 if let Err(_) = reader_sender.send(msg) {
27 break;
28 }
25 } 29 }
26 Ok(()) 30 Ok(())
27 }); 31 });
diff --git a/crates/ra_lsp_server/Cargo.toml b/crates/ra_lsp_server/Cargo.toml
index 646df2497..b1e8987fe 100644
--- a/crates/ra_lsp_server/Cargo.toml
+++ b/crates/ra_lsp_server/Cargo.toml
@@ -13,7 +13,7 @@ failure_derive = "0.1.2"
13serde_json = "1.0.24" 13serde_json = "1.0.24"
14serde = "1.0.83" 14serde = "1.0.83"
15drop_bomb = "0.1.0" 15drop_bomb = "0.1.0"
16crossbeam-channel = "0.2.4" 16crossbeam-channel = "0.3.5"
17flexi_logger = "0.10.0" 17flexi_logger = "0.10.0"
18log = "0.4.3" 18log = "0.4.3"
19url_serde = "0.2.0" 19url_serde = "0.2.0"
diff --git a/crates/ra_lsp_server/src/main_loop.rs b/crates/ra_lsp_server/src/main_loop.rs
index 97c1be778..3ebae4ecd 100644
--- a/crates/ra_lsp_server/src/main_loop.rs
+++ b/crates/ra_lsp_server/src/main_loop.rs
@@ -7,7 +7,7 @@ use std::{
7 sync::Arc, 7 sync::Arc,
8}; 8};
9 9
10use crossbeam_channel::{unbounded, select, Receiver, Sender}; 10use crossbeam_channel::{unbounded, select, Receiver, Sender, RecvError};
11use gen_lsp_server::{ 11use gen_lsp_server::{
12 handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse, 12 handle_shutdown, ErrorCode, RawMessage, RawNotification, RawRequest, RawResponse,
13}; 13};
@@ -62,7 +62,7 @@ pub fn main_loop(
62 let (task_sender, task_receiver) = unbounded::<Task>(); 62 let (task_sender, task_receiver) = unbounded::<Task>();
63 let (ws_worker, ws_watcher) = workspace_loader(); 63 let (ws_worker, ws_watcher) = workspace_loader();
64 64
65 ws_worker.send(ws_root.clone()); 65 ws_worker.send(ws_root.clone()).unwrap();
66 // FIXME: support dynamic workspace loading. 66 // FIXME: support dynamic workspace loading.
67 let workspaces = match ws_worker.recv().unwrap() { 67 let workspaces = match ws_worker.recv().unwrap() {
68 Ok(ws) => vec![ws], 68 Ok(ws) => vec![ws],
@@ -95,7 +95,9 @@ pub fn main_loop(
95 ); 95 );
96 96
97 log::info!("waiting for tasks to finish..."); 97 log::info!("waiting for tasks to finish...");
98 task_receiver.for_each(|task| on_task(task, msg_sender, &mut pending_requests)); 98 task_receiver
99 .into_iter()
100 .for_each(|task| on_task(task, msg_sender, &mut pending_requests));
99 log::info!("...tasks have finished"); 101 log::info!("...tasks have finished");
100 log::info!("joining threadpool..."); 102 log::info!("joining threadpool...");
101 drop(pool); 103 drop(pool);
@@ -170,16 +172,16 @@ fn main_loop_inner(
170 loop { 172 loop {
171 log::trace!("selecting"); 173 log::trace!("selecting");
172 let event = select! { 174 let event = select! {
173 recv(msg_receiver, msg) => match msg { 175 recv(msg_receiver) -> msg => match msg {
174 Some(msg) => Event::Msg(msg), 176 Ok(msg) => Event::Msg(msg),
175 None => bail!("client exited without shutdown"), 177 Err(RecvError) => bail!("client exited without shutdown"),
176 }, 178 },
177 recv(task_receiver, task) => Event::Task(task.unwrap()), 179 recv(task_receiver) -> task => Event::Task(task.unwrap()),
178 recv(state.vfs.read().task_receiver(), task) => match task { 180 recv(state.vfs.read().task_receiver()) -> task => match task {
179 None => bail!("vfs died"), 181 Ok(task) => Event::Vfs(task),
180 Some(task) => Event::Vfs(task), 182 Err(RecvError) => bail!("vfs died"),
181 } 183 },
182 recv(libdata_receiver, data) => Event::Lib(data.unwrap()) 184 recv(libdata_receiver) -> data => Event::Lib(data.unwrap())
183 }; 185 };
184 log::info!("loop_turn = {:?}", event); 186 log::info!("loop_turn = {:?}", event);
185 let start = std::time::Instant::now(); 187 let start = std::time::Instant::now();
@@ -209,7 +211,7 @@ fn main_loop_inner(
209 ErrorCode::MethodNotFound as i32, 211 ErrorCode::MethodNotFound as i32,
210 "unknown request".to_string(), 212 "unknown request".to_string(),
211 ); 213 );
212 msg_sender.send(RawMessage::Response(resp)) 214 msg_sender.send(RawMessage::Response(resp)).unwrap()
213 } 215 }
214 } 216 }
215 } 217 }
@@ -229,7 +231,7 @@ fn main_loop_inner(
229 log::info!("indexing {:?} ... ", root); 231 log::info!("indexing {:?} ... ", root);
230 let data = LibraryData::prepare(root, files); 232 let data = LibraryData::prepare(root, files);
231 log::info!("indexed {:?} {:?}", start.elapsed(), root); 233 log::info!("indexed {:?} {:?}", start.elapsed(), root);
232 sender.send(data); 234 sender.send(data).unwrap();
233 }); 235 });
234 } 236 }
235 if state.roots_to_scan == 0 { 237 if state.roots_to_scan == 0 {
@@ -253,10 +255,12 @@ fn on_task(task: Task, msg_sender: &Sender<RawMessage>, pending_requests: &mut F
253 match task { 255 match task {
254 Task::Respond(response) => { 256 Task::Respond(response) => {
255 if pending_requests.remove(&response.id) { 257 if pending_requests.remove(&response.id) {
256 msg_sender.send(RawMessage::Response(response)) 258 msg_sender.send(RawMessage::Response(response)).unwrap();
257 } 259 }
258 } 260 }
259 Task::Notify(n) => msg_sender.send(RawMessage::Notification(n)), 261 Task::Notify(n) => {
262 msg_sender.send(RawMessage::Notification(n)).unwrap();
263 }
260 } 264 }
261} 265}
262 266
@@ -328,7 +332,7 @@ fn on_notification(
328 ErrorCode::RequestCancelled as i32, 332 ErrorCode::RequestCancelled as i32,
329 "canceled by client".to_string(), 333 "canceled by client".to_string(),
330 ); 334 );
331 msg_sender.send(RawMessage::Response(response)) 335 msg_sender.send(RawMessage::Response(response)).unwrap()
332 } 336 }
333 return Ok(()); 337 return Ok(());
334 } 338 }
@@ -381,7 +385,7 @@ fn on_notification(
381 diagnostics: Vec::new(), 385 diagnostics: Vec::new(),
382 }; 386 };
383 let not = RawNotification::new::<req::PublishDiagnostics>(&params); 387 let not = RawNotification::new::<req::PublishDiagnostics>(&params);
384 msg_sender.send(RawMessage::Notification(not)); 388 msg_sender.send(RawMessage::Notification(not)).unwrap();
385 return Ok(()); 389 return Ok(());
386 } 390 }
387 Err(not) => not, 391 Err(not) => not,
@@ -441,7 +445,7 @@ impl<'a> PoolDispatcher<'a> {
441 }, 445 },
442 }; 446 };
443 let task = Task::Respond(resp); 447 let task = Task::Respond(resp);
444 sender.send(task); 448 sender.send(task).unwrap();
445 }); 449 });
446 self.res = Some(id); 450 self.res = Some(id);
447 } 451 }
@@ -476,7 +480,7 @@ fn update_file_notifications_on_threadpool(
476 } 480 }
477 Ok(params) => { 481 Ok(params) => {
478 let not = RawNotification::new::<req::PublishDiagnostics>(&params); 482 let not = RawNotification::new::<req::PublishDiagnostics>(&params);
479 sender.send(Task::Notify(not)); 483 sender.send(Task::Notify(not)).unwrap();
480 } 484 }
481 } 485 }
482 if publish_decorations { 486 if publish_decorations {
@@ -488,7 +492,7 @@ fn update_file_notifications_on_threadpool(
488 } 492 }
489 Ok(params) => { 493 Ok(params) => {
490 let not = RawNotification::new::<req::PublishDecorations>(&params); 494 let not = RawNotification::new::<req::PublishDecorations>(&params);
491 sender.send(Task::Notify(not)) 495 sender.send(Task::Notify(not)).unwrap();
492 } 496 }
493 } 497 }
494 } 498 }
@@ -501,7 +505,7 @@ fn feedback(intrnal_mode: bool, msg: &str, sender: &Sender<RawMessage>) {
501 return; 505 return;
502 } 506 }
503 let not = RawNotification::new::<req::InternalFeedback>(&msg.to_string()); 507 let not = RawNotification::new::<req::InternalFeedback>(&msg.to_string());
504 sender.send(RawMessage::Notification(not)); 508 sender.send(RawMessage::Notification(not)).unwrap();
505} 509}
506 510
507fn is_canceled(e: &failure::Error) -> bool { 511fn is_canceled(e: &failure::Error) -> bool {
diff --git a/crates/ra_lsp_server/src/project_model.rs b/crates/ra_lsp_server/src/project_model.rs
index 5852a157d..ae2149463 100644
--- a/crates/ra_lsp_server/src/project_model.rs
+++ b/crates/ra_lsp_server/src/project_model.rs
@@ -204,8 +204,10 @@ pub fn workspace_loader() -> (Worker<PathBuf, Result<CargoWorkspace>>, WorkerHan
204 1, 204 1,
205 |input_receiver, output_sender| { 205 |input_receiver, output_sender| {
206 input_receiver 206 input_receiver
207 .into_iter()
207 .map(|path| CargoWorkspace::from_cargo_metadata(path.as_path())) 208 .map(|path| CargoWorkspace::from_cargo_metadata(path.as_path()))
208 .for_each(|it| output_sender.send(it)) 209 .try_for_each(|it| output_sender.send(it))
210 .unwrap()
209 }, 211 },
210 ) 212 )
211} 213}
diff --git a/crates/ra_lsp_server/tests/heavy_tests/support.rs b/crates/ra_lsp_server/tests/heavy_tests/support.rs
index c14d287ca..82ba12f87 100644
--- a/crates/ra_lsp_server/tests/heavy_tests/support.rs
+++ b/crates/ra_lsp_server/tests/heavy_tests/support.rs
@@ -118,7 +118,11 @@ impl Server {
118 } 118 }
119 fn send_request_(&self, r: RawRequest) -> Value { 119 fn send_request_(&self, r: RawRequest) -> Value {
120 let id = r.id; 120 let id = r.id;
121 self.worker.as_ref().unwrap().send(RawMessage::Request(r)); 121 self.worker
122 .as_ref()
123 .unwrap()
124 .send(RawMessage::Request(r))
125 .unwrap();
122 while let Some(msg) = self.recv() { 126 while let Some(msg) = self.recv() {
123 match msg { 127 match msg {
124 RawMessage::Request(req) => panic!("unexpected request: {:?}", req), 128 RawMessage::Request(req) => panic!("unexpected request: {:?}", req),
@@ -167,7 +171,8 @@ impl Server {
167 self.worker 171 self.worker
168 .as_ref() 172 .as_ref()
169 .unwrap() 173 .unwrap()
170 .send(RawMessage::Notification(not)); 174 .send(RawMessage::Notification(not))
175 .unwrap();
171 } 176 }
172} 177}
173 178
@@ -185,7 +190,7 @@ impl Drop for Server {
185fn recv_timeout(receiver: &Receiver<RawMessage>) -> Option<RawMessage> { 190fn recv_timeout(receiver: &Receiver<RawMessage>) -> Option<RawMessage> {
186 let timeout = Duration::from_secs(5); 191 let timeout = Duration::from_secs(5);
187 select! { 192 select! {
188 recv(receiver, msg) => msg, 193 recv(receiver) -> msg => msg.ok(),
189 recv(after(timeout)) => panic!("timed out"), 194 recv(after(timeout)) -> _ => panic!("timed out"),
190 } 195 }
191} 196}
diff --git a/crates/ra_vfs/Cargo.toml b/crates/ra_vfs/Cargo.toml
index ccea8a866..7c170cdfc 100644
--- a/crates/ra_vfs/Cargo.toml
+++ b/crates/ra_vfs/Cargo.toml
@@ -8,7 +8,7 @@ authors = ["Aleksey Kladov <[email protected]>"]
8walkdir = "2.2.7" 8walkdir = "2.2.7"
9relative-path = "0.4.0" 9relative-path = "0.4.0"
10rustc-hash = "1.0" 10rustc-hash = "1.0"
11crossbeam-channel = "0.2.4" 11crossbeam-channel = "0.3.5"
12log = "0.4.6" 12log = "0.4.6"
13 13
14thread_worker = { path = "../thread_worker" } 14thread_worker = { path = "../thread_worker" }
diff --git a/crates/ra_vfs/src/io.rs b/crates/ra_vfs/src/io.rs
index 4cfdb83da..80328ad18 100644
--- a/crates/ra_vfs/src/io.rs
+++ b/crates/ra_vfs/src/io.rs
@@ -32,8 +32,10 @@ pub(crate) type Worker = thread_worker::Worker<Task, TaskResult>;
32pub(crate) fn start() -> (Worker, WorkerHandle) { 32pub(crate) fn start() -> (Worker, WorkerHandle) {
33 thread_worker::spawn("vfs", 128, |input_receiver, output_sender| { 33 thread_worker::spawn("vfs", 128, |input_receiver, output_sender| {
34 input_receiver 34 input_receiver
35 .into_iter()
35 .map(handle_task) 36 .map(handle_task)
36 .for_each(|it| output_sender.send(it)) 37 .try_for_each(|it| output_sender.send(it))
38 .unwrap()
37 }) 39 })
38} 40}
39 41
diff --git a/crates/ra_vfs/src/lib.rs b/crates/ra_vfs/src/lib.rs
index 90d5e21f4..757eac95b 100644
--- a/crates/ra_vfs/src/lib.rs
+++ b/crates/ra_vfs/src/lib.rs
@@ -148,7 +148,7 @@ impl Vfs {
148 path: path.clone(), 148 path: path.clone(),
149 filter: Box::new(filter), 149 filter: Box::new(filter),
150 }; 150 };
151 res.worker.inp.send(task); 151 res.worker.inp.send(task).unwrap();
152 } 152 }
153 let roots = res.roots.iter().map(|(id, _)| id).collect(); 153 let roots = res.roots.iter().map(|(id, _)| id).collect();
154 (res, roots) 154 (res, roots)
diff --git a/crates/thread_worker/Cargo.toml b/crates/thread_worker/Cargo.toml
index 62d66a1a3..c74b376e2 100644
--- a/crates/thread_worker/Cargo.toml
+++ b/crates/thread_worker/Cargo.toml
@@ -6,6 +6,6 @@ authors = ["Aleksey Kladov <[email protected]>"]
6 6
7[dependencies] 7[dependencies]
8drop_bomb = "0.1.0" 8drop_bomb = "0.1.0"
9crossbeam-channel = "0.2.4" 9crossbeam-channel = "0.3.5"
10log = "0.4.3" 10log = "0.4.3"
11 11
diff --git a/crates/thread_worker/src/lib.rs b/crates/thread_worker/src/lib.rs
index 12e8bf17e..5e46f62fe 100644
--- a/crates/thread_worker/src/lib.rs
+++ b/crates/thread_worker/src/lib.rs
@@ -2,7 +2,7 @@
2 2
3use std::thread; 3use std::thread;
4 4
5use crossbeam_channel::{bounded, unbounded, Receiver, Sender}; 5use crossbeam_channel::{bounded, unbounded, Receiver, Sender, RecvError, SendError};
6use drop_bomb::DropBomb; 6use drop_bomb::DropBomb;
7 7
8pub struct Worker<I, O> { 8pub struct Worker<I, O> {
@@ -34,10 +34,10 @@ impl<I, O> Worker<I, O> {
34 self.out 34 self.out
35 } 35 }
36 36
37 pub fn send(&self, item: I) { 37 pub fn send(&self, item: I) -> Result<(), SendError<I>> {
38 self.inp.send(item) 38 self.inp.send(item)
39 } 39 }
40 pub fn recv(&self) -> Option<O> { 40 pub fn recv(&self) -> Result<O, RecvError> {
41 self.out.recv() 41 self.out.recv()
42 } 42 }
43} 43}