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 <edwin0cheng@gmail.com>
This commit is contained in:
commit
44e6c2cb54
@ -4,17 +4,8 @@ use crate::{expand_task, list_macros};
|
||||
use ra_proc_macro::msg::{self, Message};
|
||||
use std::io;
|
||||
|
||||
pub fn run() {
|
||||
loop {
|
||||
let req = match read_request() {
|
||||
Err(err) => {
|
||||
eprintln!("Read message error on ra_proc_macro_srv: {}", err);
|
||||
continue;
|
||||
}
|
||||
Ok(None) => continue,
|
||||
Ok(Some(req)) => req,
|
||||
};
|
||||
|
||||
pub fn run() -> io::Result<()> {
|
||||
while let Some(req) = read_request()? {
|
||||
let res = match req {
|
||||
msg::Request::ListMacro(task) => Ok(msg::Response::ListMacro(list_macros(&task))),
|
||||
msg::Request::ExpansionMacro(task) => {
|
||||
@ -33,6 +24,8 @@ pub fn run() {
|
||||
eprintln!("Write message error: {}", err);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn read_request() -> io::Result<Option<msg::Request>> {
|
||||
|
@ -66,7 +66,7 @@ fn setup_logging() -> Result<()> {
|
||||
}
|
||||
|
||||
fn run_proc_macro_srv() -> Result<()> {
|
||||
ra_proc_macro_srv::cli::run();
|
||||
ra_proc_macro_srv::cli::run()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user