Skip to content

Panic proc macro srv if read request failed #4101

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 4 additions & 11 deletions crates/ra_proc_macro_srv/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand All @@ -33,6 +24,8 @@ pub fn run() {
eprintln!("Write message error: {}", err);
}
}

Ok(())
}

fn read_request() -> io::Result<Option<msg::Request>> {
Expand Down
2 changes: 1 addition & 1 deletion crates/rust-analyzer/src/bin/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(())
}

Expand Down