Skip to content

Commit 44e6c2c

Browse files
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]>
2 parents ffba39a + a83d174 commit 44e6c2c

File tree

2 files changed

+5
-12
lines changed

2 files changed

+5
-12
lines changed

crates/ra_proc_macro_srv/src/cli.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,8 @@ use crate::{expand_task, list_macros};
44
use ra_proc_macro::msg::{self, Message};
55
use std::io;
66

7-
pub fn run() {
8-
loop {
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-
7+
pub fn run() -> io::Result<()> {
8+
while let Some(req) = read_request()? {
189
let res = match req {
1910
msg::Request::ListMacro(task) => Ok(msg::Response::ListMacro(list_macros(&task))),
2011
msg::Request::ExpansionMacro(task) => {
@@ -33,6 +24,8 @@ pub fn run() {
3324
eprintln!("Write message error: {}", err);
3425
}
3526
}
27+
28+
Ok(())
3629
}
3730

3831
fn read_request() -> io::Result<Option<msg::Request>> {

crates/rust-analyzer/src/bin/main.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ fn setup_logging() -> Result<()> {
6666
}
6767

6868
fn run_proc_macro_srv() -> Result<()> {
69-
ra_proc_macro_srv::cli::run();
69+
ra_proc_macro_srv::cli::run()?;
7070
Ok(())
7171
}
7272

0 commit comments

Comments
 (0)