diff options
-rw-r--r-- | Cargo.lock | 24 | ||||
-rw-r--r-- | crates/flycheck/src/lib.rs | 208 | ||||
-rw-r--r-- | crates/ra_hir_ty/Cargo.toml | 4 | ||||
-rw-r--r-- | crates/ra_ide/src/inlay_hints.rs | 3 | ||||
-rw-r--r-- | crates/rust-analyzer/src/line_endings.rs | 14 | ||||
-rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 6 | ||||
-rw-r--r-- | crates/vfs-notify/src/lib.rs | 8 |
7 files changed, 147 insertions, 120 deletions
diff --git a/Cargo.lock b/Cargo.lock index dc758a1f0..b19d697f5 100644 --- a/Cargo.lock +++ b/Cargo.lock | |||
@@ -135,8 +135,9 @@ checksum = "4785bdd1c96b2a846b2bd7cc02e86b6b3dbf14e7e53446c4f54c92a361040822" | |||
135 | 135 | ||
136 | [[package]] | 136 | [[package]] |
137 | name = "chalk-derive" | 137 | name = "chalk-derive" |
138 | version = "0.15.0-dev.0" | 138 | version = "0.15.0" |
139 | source = "git+https://github.com/rust-lang/chalk#57037a53f7decc965d25972606c3ea930e9cb39f" | 139 | source = "registry+https://github.com/rust-lang/crates.io-index" |
140 | checksum = "c7379caa72d04103fcfd9bde5642b816f58e3ffd6a0d39347e9e35a066648226" | ||
140 | dependencies = [ | 141 | dependencies = [ |
141 | "proc-macro2", | 142 | "proc-macro2", |
142 | "quote", | 143 | "quote", |
@@ -146,8 +147,9 @@ dependencies = [ | |||
146 | 147 | ||
147 | [[package]] | 148 | [[package]] |
148 | name = "chalk-engine" | 149 | name = "chalk-engine" |
149 | version = "0.15.0-dev.0" | 150 | version = "0.15.0" |
150 | source = "git+https://github.com/rust-lang/chalk#57037a53f7decc965d25972606c3ea930e9cb39f" | 151 | source = "registry+https://github.com/rust-lang/crates.io-index" |
152 | checksum = "8e8afe48b5663504b485791ab4fae69cf4864869a71ceec9c758fd4d03423722" | ||
151 | dependencies = [ | 153 | dependencies = [ |
152 | "chalk-derive", | 154 | "chalk-derive", |
153 | "chalk-ir", | 155 | "chalk-ir", |
@@ -157,8 +159,9 @@ dependencies = [ | |||
157 | 159 | ||
158 | [[package]] | 160 | [[package]] |
159 | name = "chalk-ir" | 161 | name = "chalk-ir" |
160 | version = "0.15.0-dev.0" | 162 | version = "0.15.0" |
161 | source = "git+https://github.com/rust-lang/chalk#57037a53f7decc965d25972606c3ea930e9cb39f" | 163 | source = "registry+https://github.com/rust-lang/crates.io-index" |
164 | checksum = "231e391a03c1fc45874171d92be9542efedc939bac59d9501ee28b9521feb406" | ||
162 | dependencies = [ | 165 | dependencies = [ |
163 | "chalk-derive", | 166 | "chalk-derive", |
164 | "lazy_static", | 167 | "lazy_static", |
@@ -166,8 +169,9 @@ dependencies = [ | |||
166 | 169 | ||
167 | [[package]] | 170 | [[package]] |
168 | name = "chalk-solve" | 171 | name = "chalk-solve" |
169 | version = "0.15.0-dev.0" | 172 | version = "0.15.0" |
170 | source = "git+https://github.com/rust-lang/chalk#57037a53f7decc965d25972606c3ea930e9cb39f" | 173 | source = "registry+https://github.com/rust-lang/crates.io-index" |
174 | checksum = "72c969c0fd06ad50538253327ca3445ff02cc9d0209f94c3cbf198ad9d365b48" | ||
171 | dependencies = [ | 175 | dependencies = [ |
172 | "chalk-derive", | 176 | "chalk-derive", |
173 | "chalk-engine", | 177 | "chalk-engine", |
@@ -554,9 +558,9 @@ dependencies = [ | |||
554 | 558 | ||
555 | [[package]] | 559 | [[package]] |
556 | name = "instant" | 560 | name = "instant" |
557 | version = "0.1.4" | 561 | version = "0.1.5" |
558 | source = "registry+https://github.com/rust-lang/crates.io-index" | 562 | source = "registry+https://github.com/rust-lang/crates.io-index" |
559 | checksum = "7777a24a1ce5de49fcdde84ec46efa487c3af49d5b6e6e0a50367cc5c1096182" | 563 | checksum = "69da7ce1490173c2bf4d26bc8be429aaeeaf4cce6c4b970b7949651fa17655fe" |
560 | 564 | ||
561 | [[package]] | 565 | [[package]] |
562 | name = "iovec" | 566 | name = "iovec" |
diff --git a/crates/flycheck/src/lib.rs b/crates/flycheck/src/lib.rs index 92ec4f92e..1023d3040 100644 --- a/crates/flycheck/src/lib.rs +++ b/crates/flycheck/src/lib.rs | |||
@@ -5,8 +5,9 @@ | |||
5 | use std::{ | 5 | use std::{ |
6 | fmt, | 6 | fmt, |
7 | io::{self, BufReader}, | 7 | io::{self, BufReader}, |
8 | ops, | ||
8 | path::PathBuf, | 9 | path::PathBuf, |
9 | process::{Command, Stdio}, | 10 | process::{self, Command, Stdio}, |
10 | time::Duration, | 11 | time::Duration, |
11 | }; | 12 | }; |
12 | 13 | ||
@@ -49,8 +50,8 @@ impl fmt::Display for FlycheckConfig { | |||
49 | #[derive(Debug)] | 50 | #[derive(Debug)] |
50 | pub struct FlycheckHandle { | 51 | pub struct FlycheckHandle { |
51 | // XXX: drop order is significant | 52 | // XXX: drop order is significant |
52 | cmd_send: Sender<Restart>, | 53 | sender: Sender<Restart>, |
53 | handle: jod_thread::JoinHandle, | 54 | thread: jod_thread::JoinHandle, |
54 | } | 55 | } |
55 | 56 | ||
56 | impl FlycheckHandle { | 57 | impl FlycheckHandle { |
@@ -59,16 +60,15 @@ impl FlycheckHandle { | |||
59 | config: FlycheckConfig, | 60 | config: FlycheckConfig, |
60 | workspace_root: PathBuf, | 61 | workspace_root: PathBuf, |
61 | ) -> FlycheckHandle { | 62 | ) -> FlycheckHandle { |
62 | let (cmd_send, cmd_recv) = unbounded::<Restart>(); | 63 | let actor = FlycheckActor::new(sender, config, workspace_root); |
63 | let handle = jod_thread::spawn(move || { | 64 | let (sender, receiver) = unbounded::<Restart>(); |
64 | FlycheckActor::new(sender, config, workspace_root).run(cmd_recv); | 65 | let thread = jod_thread::spawn(move || actor.run(receiver)); |
65 | }); | 66 | FlycheckHandle { sender, thread } |
66 | FlycheckHandle { cmd_send, handle } | ||
67 | } | 67 | } |
68 | 68 | ||
69 | /// Schedule a re-start of the cargo check worker. | 69 | /// Schedule a re-start of the cargo check worker. |
70 | pub fn update(&self) { | 70 | pub fn update(&self) { |
71 | self.cmd_send.send(Restart).unwrap(); | 71 | self.sender.send(Restart).unwrap(); |
72 | } | 72 | } |
73 | } | 73 | } |
74 | 74 | ||
@@ -85,7 +85,7 @@ pub enum Message { | |||
85 | pub enum Progress { | 85 | pub enum Progress { |
86 | DidStart, | 86 | DidStart, |
87 | DidCheckCrate(String), | 87 | DidCheckCrate(String), |
88 | DidFinish, | 88 | DidFinish(io::Result<()>), |
89 | DidCancel, | 89 | DidCancel, |
90 | } | 90 | } |
91 | 91 | ||
@@ -100,8 +100,7 @@ struct FlycheckActor { | |||
100 | /// doesn't provide a way to read sub-process output without blocking, so we | 100 | /// doesn't provide a way to read sub-process output without blocking, so we |
101 | /// have to wrap sub-processes output handling in a thread and pass messages | 101 | /// have to wrap sub-processes output handling in a thread and pass messages |
102 | /// back over a channel. | 102 | /// back over a channel. |
103 | // XXX: drop order is significant | 103 | cargo_handle: Option<CargoHandle>, |
104 | check_process: Option<(Receiver<cargo_metadata::Message>, jod_thread::JoinHandle)>, | ||
105 | } | 104 | } |
106 | 105 | ||
107 | enum Event { | 106 | enum Event { |
@@ -115,29 +114,36 @@ impl FlycheckActor { | |||
115 | config: FlycheckConfig, | 114 | config: FlycheckConfig, |
116 | workspace_root: PathBuf, | 115 | workspace_root: PathBuf, |
117 | ) -> FlycheckActor { | 116 | ) -> FlycheckActor { |
118 | FlycheckActor { sender, config, workspace_root, check_process: None } | 117 | FlycheckActor { sender, config, workspace_root, cargo_handle: None } |
119 | } | 118 | } |
120 | fn next_event(&self, inbox: &Receiver<Restart>) -> Option<Event> { | 119 | fn next_event(&self, inbox: &Receiver<Restart>) -> Option<Event> { |
121 | let check_chan = self.check_process.as_ref().map(|(chan, _thread)| chan); | 120 | let check_chan = self.cargo_handle.as_ref().map(|cargo| &cargo.receiver); |
122 | select! { | 121 | select! { |
123 | recv(inbox) -> msg => msg.ok().map(Event::Restart), | 122 | recv(inbox) -> msg => msg.ok().map(Event::Restart), |
124 | recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())), | 123 | recv(check_chan.unwrap_or(&never())) -> msg => Some(Event::CheckEvent(msg.ok())), |
125 | } | 124 | } |
126 | } | 125 | } |
127 | fn run(&mut self, inbox: Receiver<Restart>) { | 126 | fn run(mut self, inbox: Receiver<Restart>) { |
128 | while let Some(event) = self.next_event(&inbox) { | 127 | while let Some(event) = self.next_event(&inbox) { |
129 | match event { | 128 | match event { |
130 | Event::Restart(Restart) => { | 129 | Event::Restart(Restart) => { |
131 | while let Ok(Restart) = inbox.recv_timeout(Duration::from_millis(50)) {} | 130 | while let Ok(Restart) = inbox.recv_timeout(Duration::from_millis(50)) {} |
131 | |||
132 | self.cancel_check_process(); | 132 | self.cancel_check_process(); |
133 | self.check_process = Some(self.start_check_process()); | 133 | |
134 | self.send(Message::Progress(Progress::DidStart)); | 134 | let mut command = self.check_command(); |
135 | command.stdout(Stdio::piped()).stderr(Stdio::null()).stdin(Stdio::null()); | ||
136 | if let Ok(child) = command.spawn().map(JodChild) { | ||
137 | self.cargo_handle = Some(CargoHandle::spawn(child)); | ||
138 | self.send(Message::Progress(Progress::DidStart)); | ||
139 | } | ||
135 | } | 140 | } |
136 | Event::CheckEvent(None) => { | 141 | Event::CheckEvent(None) => { |
137 | // Watcher finished, replace it with a never channel to | 142 | // Watcher finished, replace it with a never channel to |
138 | // avoid busy-waiting. | 143 | // avoid busy-waiting. |
139 | assert!(self.check_process.take().is_some()); | 144 | let cargo_handle = self.cargo_handle.take().unwrap(); |
140 | self.send(Message::Progress(Progress::DidFinish)); | 145 | let res = cargo_handle.join(); |
146 | self.send(Message::Progress(Progress::DidFinish(res))); | ||
141 | } | 147 | } |
142 | Event::CheckEvent(Some(message)) => match message { | 148 | Event::CheckEvent(Some(message)) => match message { |
143 | cargo_metadata::Message::CompilerArtifact(msg) => { | 149 | cargo_metadata::Message::CompilerArtifact(msg) => { |
@@ -162,11 +168,11 @@ impl FlycheckActor { | |||
162 | self.cancel_check_process(); | 168 | self.cancel_check_process(); |
163 | } | 169 | } |
164 | fn cancel_check_process(&mut self) { | 170 | fn cancel_check_process(&mut self) { |
165 | if self.check_process.take().is_some() { | 171 | if self.cargo_handle.take().is_some() { |
166 | self.send(Message::Progress(Progress::DidCancel)); | 172 | self.send(Message::Progress(Progress::DidCancel)); |
167 | } | 173 | } |
168 | } | 174 | } |
169 | fn start_check_process(&self) -> (Receiver<cargo_metadata::Message>, jod_thread::JoinHandle) { | 175 | fn check_command(&self) -> Command { |
170 | let mut cmd = match &self.config { | 176 | let mut cmd = match &self.config { |
171 | FlycheckConfig::CargoCommand { | 177 | FlycheckConfig::CargoCommand { |
172 | command, | 178 | command, |
@@ -198,33 +204,7 @@ impl FlycheckActor { | |||
198 | } | 204 | } |
199 | }; | 205 | }; |
200 | cmd.current_dir(&self.workspace_root); | 206 | cmd.current_dir(&self.workspace_root); |
201 | 207 | cmd | |
202 | let (message_send, message_recv) = unbounded(); | ||
203 | let thread = jod_thread::spawn(move || { | ||
204 | // If we trigger an error here, we will do so in the loop instead, | ||
205 | // which will break out of the loop, and continue the shutdown | ||
206 | let res = run_cargo(cmd, &mut |message| { | ||
207 | // Skip certain kinds of messages to only spend time on what's useful | ||
208 | match &message { | ||
209 | cargo_metadata::Message::CompilerArtifact(artifact) if artifact.fresh => { | ||
210 | return true | ||
211 | } | ||
212 | cargo_metadata::Message::BuildScriptExecuted(_) | ||
213 | | cargo_metadata::Message::Unknown => return true, | ||
214 | _ => {} | ||
215 | } | ||
216 | |||
217 | // if the send channel was closed, we want to shutdown | ||
218 | message_send.send(message).is_ok() | ||
219 | }); | ||
220 | |||
221 | if let Err(err) = res { | ||
222 | // FIXME: make the `message_send` to be `Sender<Result<CheckEvent, CargoError>>` | ||
223 | // to display user-caused misconfiguration errors instead of just logging them here | ||
224 | log::error!("Cargo watcher failed {:?}", err); | ||
225 | } | ||
226 | }); | ||
227 | (message_recv, thread) | ||
228 | } | 208 | } |
229 | 209 | ||
230 | fn send(&self, check_task: Message) { | 210 | fn send(&self, check_task: Message) { |
@@ -232,54 +212,104 @@ impl FlycheckActor { | |||
232 | } | 212 | } |
233 | } | 213 | } |
234 | 214 | ||
235 | fn run_cargo( | 215 | struct CargoHandle { |
236 | mut command: Command, | 216 | child: JodChild, |
237 | on_message: &mut dyn FnMut(cargo_metadata::Message) -> bool, | 217 | #[allow(unused)] |
238 | ) -> io::Result<()> { | 218 | thread: jod_thread::JoinHandle<io::Result<bool>>, |
239 | let mut child = | 219 | receiver: Receiver<cargo_metadata::Message>, |
240 | command.stdout(Stdio::piped()).stderr(Stdio::null()).stdin(Stdio::null()).spawn()?; | 220 | } |
241 | 221 | ||
242 | // We manually read a line at a time, instead of using serde's | 222 | impl CargoHandle { |
243 | // stream deserializers, because the deserializer cannot recover | 223 | fn spawn(mut child: JodChild) -> CargoHandle { |
244 | // from an error, resulting in it getting stuck, because we try to | 224 | let child_stdout = child.stdout.take().unwrap(); |
245 | // be resillient against failures. | 225 | let (sender, receiver) = unbounded(); |
246 | // | 226 | let actor = CargoActor::new(child_stdout, sender); |
247 | // Because cargo only outputs one JSON object per line, we can | 227 | let thread = jod_thread::spawn(move || actor.run()); |
248 | // simply skip a line if it doesn't parse, which just ignores any | 228 | CargoHandle { child, thread, receiver } |
249 | // erroneus output. | 229 | } |
250 | let stdout = BufReader::new(child.stdout.take().unwrap()); | 230 | fn join(mut self) -> io::Result<()> { |
251 | let mut read_at_least_one_message = false; | 231 | // It is okay to ignore the result, as it only errors if the process is already dead |
252 | for message in cargo_metadata::Message::parse_stream(stdout) { | 232 | let _ = self.child.kill(); |
253 | let message = match message { | 233 | let exit_status = self.child.wait()?; |
254 | Ok(message) => message, | 234 | let read_at_least_one_message = self.thread.join()?; |
255 | Err(err) => { | 235 | if !exit_status.success() && !read_at_least_one_message { |
256 | log::error!("Invalid json from cargo check, ignoring ({})", err); | 236 | // FIXME: Read the stderr to display the reason, see `read2()` reference in PR comment: |
257 | continue; | 237 | // https://github.com/rust-analyzer/rust-analyzer/pull/3632#discussion_r395605298 |
258 | } | 238 | return Err(io::Error::new( |
259 | }; | 239 | io::ErrorKind::Other, |
240 | format!( | ||
241 | "Cargo watcher failed,the command produced no valid metadata (exit code: {:?})", | ||
242 | exit_status | ||
243 | ), | ||
244 | )); | ||
245 | } | ||
246 | Ok(()) | ||
247 | } | ||
248 | } | ||
249 | |||
250 | struct CargoActor { | ||
251 | child_stdout: process::ChildStdout, | ||
252 | sender: Sender<cargo_metadata::Message>, | ||
253 | } | ||
254 | |||
255 | impl CargoActor { | ||
256 | fn new( | ||
257 | child_stdout: process::ChildStdout, | ||
258 | sender: Sender<cargo_metadata::Message>, | ||
259 | ) -> CargoActor { | ||
260 | CargoActor { child_stdout, sender } | ||
261 | } | ||
262 | fn run(self) -> io::Result<bool> { | ||
263 | // We manually read a line at a time, instead of using serde's | ||
264 | // stream deserializers, because the deserializer cannot recover | ||
265 | // from an error, resulting in it getting stuck, because we try to | ||
266 | // be resilient against failures. | ||
267 | // | ||
268 | // Because cargo only outputs one JSON object per line, we can | ||
269 | // simply skip a line if it doesn't parse, which just ignores any | ||
270 | // erroneus output. | ||
271 | let stdout = BufReader::new(self.child_stdout); | ||
272 | let mut read_at_least_one_message = false; | ||
273 | for message in cargo_metadata::Message::parse_stream(stdout) { | ||
274 | let message = match message { | ||
275 | Ok(message) => message, | ||
276 | Err(err) => { | ||
277 | log::error!("Invalid json from cargo check, ignoring ({})", err); | ||
278 | continue; | ||
279 | } | ||
280 | }; | ||
260 | 281 | ||
261 | read_at_least_one_message = true; | 282 | read_at_least_one_message = true; |
262 | 283 | ||
263 | if !on_message(message) { | 284 | // Skip certain kinds of messages to only spend time on what's useful |
264 | break; | 285 | match &message { |
286 | cargo_metadata::Message::CompilerArtifact(artifact) if artifact.fresh => (), | ||
287 | cargo_metadata::Message::BuildScriptExecuted(_) | ||
288 | | cargo_metadata::Message::Unknown => (), | ||
289 | _ => self.sender.send(message).unwrap(), | ||
290 | } | ||
265 | } | 291 | } |
292 | Ok(read_at_least_one_message) | ||
266 | } | 293 | } |
294 | } | ||
267 | 295 | ||
268 | // It is okay to ignore the result, as it only errors if the process is already dead | 296 | struct JodChild(process::Child); |
269 | let _ = child.kill(); | ||
270 | 297 | ||
271 | let exit_status = child.wait()?; | 298 | impl ops::Deref for JodChild { |
272 | if !exit_status.success() && !read_at_least_one_message { | 299 | type Target = process::Child; |
273 | // FIXME: Read the stderr to display the reason, see `read2()` reference in PR comment: | 300 | fn deref(&self) -> &process::Child { |
274 | // https://github.com/rust-analyzer/rust-analyzer/pull/3632#discussion_r395605298 | 301 | &self.0 |
275 | return Err(io::Error::new( | ||
276 | io::ErrorKind::Other, | ||
277 | format!( | ||
278 | "the command produced no valid metadata (exit code: {:?}): {:?}", | ||
279 | exit_status, command | ||
280 | ), | ||
281 | )); | ||
282 | } | 302 | } |
303 | } | ||
283 | 304 | ||
284 | Ok(()) | 305 | impl ops::DerefMut for JodChild { |
306 | fn deref_mut(&mut self) -> &mut process::Child { | ||
307 | &mut self.0 | ||
308 | } | ||
309 | } | ||
310 | |||
311 | impl Drop for JodChild { | ||
312 | fn drop(&mut self) { | ||
313 | let _ = self.0.kill(); | ||
314 | } | ||
285 | } | 315 | } |
diff --git a/crates/ra_hir_ty/Cargo.toml b/crates/ra_hir_ty/Cargo.toml index 407322dc1..d6df48db2 100644 --- a/crates/ra_hir_ty/Cargo.toml +++ b/crates/ra_hir_ty/Cargo.toml | |||
@@ -27,8 +27,8 @@ test_utils = { path = "../test_utils" } | |||
27 | 27 | ||
28 | scoped-tls = "1" | 28 | scoped-tls = "1" |
29 | 29 | ||
30 | chalk-solve = { version = "0.15.0-dev.0", git = "https://github.com/rust-lang/chalk" } | 30 | chalk-solve = { version = "0.15.0" } |
31 | chalk-ir = { version = "0.15.0-dev.0", git = "https://github.com/rust-lang/chalk" } | 31 | chalk-ir = { version = "0.15.0" } |
32 | 32 | ||
33 | [dev-dependencies] | 33 | [dev-dependencies] |
34 | insta = "0.16.0" | 34 | insta = "0.16.0" |
diff --git a/crates/ra_ide/src/inlay_hints.rs b/crates/ra_ide/src/inlay_hints.rs index 886346991..c87652555 100644 --- a/crates/ra_ide/src/inlay_hints.rs +++ b/crates/ra_ide/src/inlay_hints.rs | |||
@@ -258,6 +258,7 @@ fn should_show_param_name_hint( | |||
258 | if param_name.is_empty() | 258 | if param_name.is_empty() |
259 | || Some(param_name) == fn_signature.name.as_ref().map(|s| s.trim_start_matches('_')) | 259 | || Some(param_name) == fn_signature.name.as_ref().map(|s| s.trim_start_matches('_')) |
260 | || is_argument_similar_to_param_name(sema, argument, param_name) | 260 | || is_argument_similar_to_param_name(sema, argument, param_name) |
261 | || param_name.starts_with("ra_fixture") | ||
261 | { | 262 | { |
262 | return false; | 263 | return false; |
263 | } | 264 | } |
@@ -270,7 +271,7 @@ fn should_show_param_name_hint( | |||
270 | 271 | ||
271 | // avoid displaying hints for common functions like map, filter, etc. | 272 | // avoid displaying hints for common functions like map, filter, etc. |
272 | // or other obvious words used in std | 273 | // or other obvious words used in std |
273 | parameters_len != 1 || !is_obvious_param(param_name) | 274 | !(parameters_len == 1 && is_obvious_param(param_name)) |
274 | } | 275 | } |
275 | 276 | ||
276 | fn is_argument_similar_to_param_name( | 277 | fn is_argument_similar_to_param_name( |
diff --git a/crates/rust-analyzer/src/line_endings.rs b/crates/rust-analyzer/src/line_endings.rs index 7e6db954e..9f892f32e 100644 --- a/crates/rust-analyzer/src/line_endings.rs +++ b/crates/rust-analyzer/src/line_endings.rs | |||
@@ -46,19 +46,7 @@ impl LineEndings { | |||
46 | return (src, LineEndings::Dos); | 46 | return (src, LineEndings::Dos); |
47 | 47 | ||
48 | fn find_crlf(src: &[u8]) -> Option<usize> { | 48 | fn find_crlf(src: &[u8]) -> Option<usize> { |
49 | let mut search_idx = 0; | 49 | src.iter().zip(src.iter().skip(1)).position(|it| it == (&b'\r', &b'\n')) |
50 | while let Some(idx) = find_cr(&src[search_idx..]) { | ||
51 | if src[search_idx..].get(idx + 1) != Some(&b'\n') { | ||
52 | search_idx += idx + 1; | ||
53 | continue; | ||
54 | } | ||
55 | return Some(search_idx + idx); | ||
56 | } | ||
57 | None | ||
58 | } | ||
59 | |||
60 | fn find_cr(src: &[u8]) -> Option<usize> { | ||
61 | src.iter().enumerate().find_map(|(idx, &b)| if b == b'\r' { Some(idx) } else { None }) | ||
62 | } | 50 | } |
63 | } | 51 | } |
64 | } | 52 | } |
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index e5194fe41..9fd16ef3b 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs | |||
@@ -216,7 +216,11 @@ impl GlobalState { | |||
216 | flycheck::Progress::DidCheckCrate(target) => { | 216 | flycheck::Progress::DidCheckCrate(target) => { |
217 | (Progress::Report, Some(target)) | 217 | (Progress::Report, Some(target)) |
218 | } | 218 | } |
219 | flycheck::Progress::DidFinish | flycheck::Progress::DidCancel => { | 219 | flycheck::Progress::DidCancel => (Progress::End, None), |
220 | flycheck::Progress::DidFinish(result) => { | ||
221 | if let Err(err) = result { | ||
222 | log::error!("cargo check failed: {}", err) | ||
223 | } | ||
220 | (Progress::End, None) | 224 | (Progress::End, None) |
221 | } | 225 | } |
222 | }; | 226 | }; |
diff --git a/crates/vfs-notify/src/lib.rs b/crates/vfs-notify/src/lib.rs index 25ba8d798..b1ea298ae 100644 --- a/crates/vfs-notify/src/lib.rs +++ b/crates/vfs-notify/src/lib.rs | |||
@@ -10,7 +10,7 @@ mod include; | |||
10 | 10 | ||
11 | use std::convert::{TryFrom, TryInto}; | 11 | use std::convert::{TryFrom, TryInto}; |
12 | 12 | ||
13 | use crossbeam_channel::{select, unbounded, Receiver}; | 13 | use crossbeam_channel::{select, unbounded, Receiver, Sender}; |
14 | use notify::{RecommendedWatcher, RecursiveMode, Watcher}; | 14 | use notify::{RecommendedWatcher, RecursiveMode, Watcher}; |
15 | use paths::{AbsPath, AbsPathBuf}; | 15 | use paths::{AbsPath, AbsPathBuf}; |
16 | use rustc_hash::FxHashSet; | 16 | use rustc_hash::FxHashSet; |
@@ -22,8 +22,8 @@ use crate::include::Include; | |||
22 | #[derive(Debug)] | 22 | #[derive(Debug)] |
23 | pub struct NotifyHandle { | 23 | pub struct NotifyHandle { |
24 | // Relative order of fields below is significant. | 24 | // Relative order of fields below is significant. |
25 | sender: crossbeam_channel::Sender<Message>, | 25 | sender: Sender<Message>, |
26 | _thread: jod_thread::JoinHandle, | 26 | thread: jod_thread::JoinHandle, |
27 | } | 27 | } |
28 | 28 | ||
29 | #[derive(Debug)] | 29 | #[derive(Debug)] |
@@ -37,7 +37,7 @@ impl loader::Handle for NotifyHandle { | |||
37 | let actor = NotifyActor::new(sender); | 37 | let actor = NotifyActor::new(sender); |
38 | let (sender, receiver) = unbounded::<Message>(); | 38 | let (sender, receiver) = unbounded::<Message>(); |
39 | let thread = jod_thread::spawn(move || actor.run(receiver)); | 39 | let thread = jod_thread::spawn(move || actor.run(receiver)); |
40 | NotifyHandle { sender, _thread: thread } | 40 | NotifyHandle { sender, thread } |
41 | } | 41 | } |
42 | fn set_config(&mut self, config: loader::Config) { | 42 | fn set_config(&mut self, config: loader::Config) { |
43 | self.sender.send(Message::Config(config)).unwrap() | 43 | self.sender.send(Message::Config(config)).unwrap() |