Unnamed repository; edit this file 'description' to name the repository.
Fix reporting of build script errors
Jonas Schievink 2021-08-25
parent 095df7b · commit 0ff2c81
-rw-r--r--crates/project_model/src/build_scripts.rs4
-rw-r--r--crates/rust-analyzer/src/reload.rs24
2 files changed, 21 insertions, 7 deletions
diff --git a/crates/project_model/src/build_scripts.rs b/crates/project_model/src/build_scripts.rs
index fb8cc271c5..7ed7de04fb 100644
--- a/crates/project_model/src/build_scripts.rs
+++ b/crates/project_model/src/build_scripts.rs
@@ -196,6 +196,10 @@ impl WorkspaceBuildScripts {
Ok(res)
}
+
+ pub fn error(&self) -> Option<&str> {
+ self.error.as_deref()
+ }
}
// FIXME: File a better way to know if it is a dylib.
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index cc32b0e2fe..efac6d6868 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -445,19 +445,29 @@ impl GlobalState {
}
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 {
- if let Err(err) = ws {
- stdx::format_to!(buf, "rust-analyzer failed to run custom build: {:#}\n", err);
+ match ws {
+ 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() {
- return None;
+ if has_errors {
+ Some(buf)
+ } else {
+ None
}
-
- Some(buf)
}
fn reload_flycheck(&mut self) {