about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2024-12-28 17:31:11 +0000
committerGitHub <noreply@github.com>2024-12-28 17:31:11 +0000
commit47f497d6365f28bf165cef24bcb728c7f3b4ab36 (patch)
treef4299e4a6157b0846a517925792471fe023fe678
parent8d8b42df66ce7eb7a2a2d704f87b9873b4126017 (diff)
parent171be2bd58d0c3714570e405d51476beefe151af (diff)
downloadrust-47f497d6365f28bf165cef24bcb728c7f3b4ab36.tar.gz
rust-47f497d6365f28bf165cef24bcb728c7f3b4ab36.zip
Merge pull request #18778 from Veykril/push-oontvoqmxkno
fix: Fix flycheck diagnostics flickering for binary targets
-rw-r--r--src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs
index 53c145f884e..c7bb275c5f1 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs
@@ -345,6 +345,7 @@ impl FlycheckActor {
                         );
                     }
                     if self.package_status.is_empty() {
+                        tracing::trace!(flycheck_id = self.id, "clearing diagnostics");
                         // We finished without receiving any diagnostics.
                         // That means all of them are stale.
                         self.send(FlycheckMessage::ClearDiagnostics {
@@ -354,6 +355,11 @@ impl FlycheckActor {
                     } else {
                         for (package_id, status) in mem::take(&mut self.package_status) {
                             if let DiagnosticReceived::No = status {
+                                tracing::trace!(
+                                    flycheck_id = self.id,
+                                    package_id = package_id.repr,
+                                    "clearing diagnostics"
+                                );
                                 self.send(FlycheckMessage::ClearDiagnostics {
                                     id: self.id,
                                     package_id: Some(package_id),
@@ -385,9 +391,15 @@ impl FlycheckActor {
                             "diagnostic received"
                         );
                         if let Some(package_id) = &package_id {
-                            if !self.package_status.contains_key(package_id) {
-                                self.package_status
-                                    .insert(package_id.clone(), DiagnosticReceived::Yes);
+                            if let None | Some(DiagnosticReceived::No) = self
+                                .package_status
+                                .insert(package_id.clone(), DiagnosticReceived::Yes)
+                            {
+                                tracing::trace!(
+                                    flycheck_id = self.id,
+                                    package_id = package_id.repr,
+                                    "clearing diagnostics"
+                                );
                                 self.send(FlycheckMessage::ClearDiagnostics {
                                     id: self.id,
                                     package_id: Some(package_id.clone()),