Unnamed repository; edit this file 'description' to name the repository.
-rw-r--r--crates/rust-analyzer/src/config.rs1
-rw-r--r--crates/rust-analyzer/src/global_state.rs2
-rw-r--r--crates/rust-analyzer/src/handlers/notification.rs2
-rw-r--r--crates/rust-analyzer/src/main_loop.rs19
-rw-r--r--crates/rust-analyzer/src/reload.rs5
5 files changed, 16 insertions, 13 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index 05567f8f57..b1d019cb11 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -734,7 +734,6 @@ impl fmt::Display for ConfigError {
write!(
f,
"invalid config value{}:\n{}",
- self.errors.len(),
if self.errors.len() == 1 { "" } else { "s" },
errors
)
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index d68e51240b..9f4dc44402 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -75,6 +75,7 @@ pub(crate) struct GlobalState {
pub(crate) flycheck: Arc<[FlycheckHandle]>,
pub(crate) flycheck_sender: Sender<flycheck::Message>,
pub(crate) flycheck_receiver: Receiver<flycheck::Message>,
+ pub(crate) last_flycheck_error: Option<String>,
// VFS
pub(crate) loader: Handle<Box<dyn vfs::loader::Handle>, Receiver<vfs::loader::Message>>,
@@ -179,6 +180,7 @@ impl GlobalState {
flycheck: Arc::from(Vec::new()),
flycheck_sender,
flycheck_receiver,
+ last_flycheck_error: None,
vfs: Arc::new(RwLock::new((vfs::Vfs::default(), IntMap::default()))),
vfs_config_version: 0,
diff --git a/crates/rust-analyzer/src/handlers/notification.rs b/crates/rust-analyzer/src/handlers/notification.rs
index 481004988d..7074ef018a 100644
--- a/crates/rust-analyzer/src/handlers/notification.rs
+++ b/crates/rust-analyzer/src/handlers/notification.rs
@@ -169,7 +169,7 @@ pub(crate) fn handle_did_change_configuration(
// Note that json can be null according to the spec if the client can't
// provide a configuration. This is handled in Config::update below.
let mut config = Config::clone(&*this.config);
- config.update(json.take());
+ this.config_errors = config.update(json.take()).err();
this.update_configuration(config);
}
}
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs
index 49595a45ea..16d683957f 100644
--- a/crates/rust-analyzer/src/main_loop.rs
+++ b/crates/rust-analyzer/src/main_loop.rs
@@ -602,21 +602,18 @@ impl GlobalState {
(Progress::Begin, None)
}
flycheck::Progress::DidCheckCrate(target) => (Progress::Report, Some(target)),
- flycheck::Progress::DidCancel => (Progress::End, None),
+ flycheck::Progress::DidCancel => {
+ self.last_flycheck_error = None;
+ (Progress::End, None)
+ }
flycheck::Progress::DidFailToRestart(err) => {
- self.show_and_log_error(
- "cargo check failed to start".to_string(),
- Some(err),
- );
+ self.last_flycheck_error =
+ Some(format!("cargo check failed to start: {err}"));
return;
}
flycheck::Progress::DidFinish(result) => {
- if let Err(err) = result {
- self.show_and_log_error(
- "cargo check failed".to_string(),
- Some(err.to_string()),
- );
- }
+ self.last_flycheck_error =
+ result.err().map(|err| format!("cargo check failed to start: {err}"));
(Progress::End, None)
}
};
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index 5300349e7d..4e29485573 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -139,6 +139,11 @@ impl GlobalState {
status.health = lsp_ext::Health::Warning;
format_to!(message, "{err}\n");
}
+ if let Some(err) = &self.last_flycheck_error {
+ status.health = lsp_ext::Health::Warning;
+ message.push_str(err);
+ message.push('\n');
+ }
for ws in self.workspaces.iter() {
let (ProjectWorkspace::Cargo { sysroot, .. }