Fix reporting of build script errors

This commit is contained in:
Jonas Schievink 2021-08-25 17:56:39 +02:00
parent 095df7bc39
commit 0ff2c81bb9
2 changed files with 21 additions and 7 deletions

View file

@ -196,6 +196,10 @@ impl WorkspaceBuildScripts {
Ok(res) Ok(res)
} }
pub fn error(&self) -> Option<&str> {
self.error.as_deref()
}
} }
// FIXME: File a better way to know if it is a dylib. // FIXME: File a better way to know if it is a dylib.

View file

@ -445,19 +445,29 @@ impl GlobalState {
} }
fn fetch_build_data_error(&self) -> Option<String> { fn fetch_build_data_error(&self) -> Option<String> {
let mut buf = String::new(); let mut buf = "rust-analyzer failed to run build scripts:\n".to_string();
let mut has_errors = false;
for ws in &self.fetch_build_data_queue.last_op_result().1 { for ws in &self.fetch_build_data_queue.last_op_result().1 {
if let Err(err) = ws { match ws {
stdx::format_to!(buf, "rust-analyzer failed to run custom build: {:#}\n", err); Ok(data) => {
if let Some(err) = data.error() {
has_errors = true;
stdx::format_to!(buf, "{:#}\n", err);
}
}
Err(err) => {
has_errors = true;
stdx::format_to!(buf, "{:#}\n", err);
}
} }
} }
if buf.is_empty() { if has_errors {
return None;
}
Some(buf) Some(buf)
} else {
None
}
} }
fn reload_flycheck(&mut self) { fn reload_flycheck(&mut self) {