diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-04-24 02:28:53 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2020-04-24 02:28:53 +0100 |
commit | 44e6c2cb54312e14b3c7bd9d64a9fa0547c17ad7 (patch) | |
tree | 681d9ab297c4ef3062503f39cf07ef4a01896003 /crates/ra_proc_macro_srv | |
parent | ffba39aca05873d928f3253fd42893f76a8ea16b (diff) | |
parent | a83d1743a5a753b69c08760e4182878fce3fca08 (diff) |
Merge #4101
4101: Panic proc macro srv if read request failed r=matklad a=edwin0cheng
This PR fixed a bug when the rust-analyzer is killed suddenly, the `rust-analyzer proc-macro` will become stale.
Co-authored-by: Edwin Cheng <[email protected]>
Diffstat (limited to 'crates/ra_proc_macro_srv')
-rw-r--r-- | crates/ra_proc_macro_srv/src/cli.rs | 15 |
1 files changed, 4 insertions, 11 deletions
diff --git a/crates/ra_proc_macro_srv/src/cli.rs b/crates/ra_proc_macro_srv/src/cli.rs index 5f1f3ba3c..7282e5b9b 100644 --- a/crates/ra_proc_macro_srv/src/cli.rs +++ b/crates/ra_proc_macro_srv/src/cli.rs | |||
@@ -4,17 +4,8 @@ use crate::{expand_task, list_macros}; | |||
4 | use ra_proc_macro::msg::{self, Message}; | 4 | use ra_proc_macro::msg::{self, Message}; |
5 | use std::io; | 5 | use std::io; |
6 | 6 | ||
7 | pub fn run() { | 7 | pub fn run() -> io::Result<()> { |
8 | loop { | 8 | while let Some(req) = read_request()? { |
9 | let req = match read_request() { | ||
10 | Err(err) => { | ||
11 | eprintln!("Read message error on ra_proc_macro_srv: {}", err); | ||
12 | continue; | ||
13 | } | ||
14 | Ok(None) => continue, | ||
15 | Ok(Some(req)) => req, | ||
16 | }; | ||
17 | |||
18 | let res = match req { | 9 | let res = match req { |
19 | msg::Request::ListMacro(task) => Ok(msg::Response::ListMacro(list_macros(&task))), | 10 | msg::Request::ListMacro(task) => Ok(msg::Response::ListMacro(list_macros(&task))), |
20 | msg::Request::ExpansionMacro(task) => { | 11 | msg::Request::ExpansionMacro(task) => { |
@@ -33,6 +24,8 @@ pub fn run() { | |||
33 | eprintln!("Write message error: {}", err); | 24 | eprintln!("Write message error: {}", err); |
34 | } | 25 | } |
35 | } | 26 | } |
27 | |||
28 | Ok(()) | ||
36 | } | 29 | } |
37 | 30 | ||
38 | fn read_request() -> io::Result<Option<msg::Request>> { | 31 | fn read_request() -> io::Result<Option<msg::Request>> { |