about summary refs log tree commit diff
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2024-12-22 11:52:59 +0000
committerGitHub <noreply@github.com>2024-12-22 11:52:59 +0000
commit84b7c8b13c6a39ea991a030b207d4de6ff531606 (patch)
treea1155e9362c6a156c4faf2856b61904d48b63414
parent36135264a6176cfc2091ae7a31c849a6391fcbe5 (diff)
parent2a977e0e92a9b8a233f01b0997ddd925007d4285 (diff)
downloadrust-84b7c8b13c6a39ea991a030b207d4de6ff531606.tar.gz
rust-84b7c8b13c6a39ea991a030b207d4de6ff531606.zip
Merge pull request #18740 from Veykril/push-tntsvtmtlotw
fix: Fix empty check diagnostics not marking files as changed
-rw-r--r--src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs11
-rw-r--r--src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs27
-rw-r--r--src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs2
3 files changed, 20 insertions, 20 deletions
diff --git a/src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs b/src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs
index 53795c0b600..55d0edd5e0c 100644
--- a/src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs
+++ b/src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs
@@ -22,7 +22,6 @@ use hir_def::{
 
 use crate::{
     db::{HirDatabase, InternedCoroutine},
-    display::HirDisplay,
     from_assoc_type_id, from_chalk_trait_id, from_foreign_def_id,
     generics::generics,
     make_binders, make_single_type_binders,
@@ -823,13 +822,12 @@ pub(crate) fn impl_datum_query(
     let _p = tracing::info_span!("impl_datum_query").entered();
     debug!("impl_datum {:?}", impl_id);
     let impl_: hir_def::ImplId = from_chalk(db, impl_id);
-    impl_def_datum(db, krate, impl_id, impl_)
+    impl_def_datum(db, krate, impl_)
 }
 
 fn impl_def_datum(
     db: &dyn HirDatabase,
     krate: CrateId,
-    chalk_id: ImplId,
     impl_id: hir_def::ImplId,
 ) -> Arc<ImplDatum> {
     let trait_ref = db
@@ -850,13 +848,6 @@ fn impl_def_datum(
     };
     let where_clauses = convert_where_clauses(db, impl_id.into(), &bound_vars);
     let negative = impl_data.is_negative;
-    debug!(
-        "impl {:?}: {}{} where {:?}",
-        chalk_id,
-        if negative { "!" } else { "" },
-        trait_ref.display(db, db.crate_graph()[krate].edition),
-        where_clauses
-    );
 
     let polarity = if negative { rust_ir::Polarity::Negative } else { rust_ir::Polarity::Positive };
 
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs
index e64a15ae041..0b51dd87fea 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs
@@ -55,9 +55,10 @@ pub(crate) struct Fix {
 
 impl DiagnosticCollection {
     pub(crate) fn clear_check(&mut self, flycheck_id: usize) {
-        if let Some(it) = self.check.get_mut(&flycheck_id) {
-            it.clear();
-        }
+        let Some(check) = self.check.get_mut(&flycheck_id) else {
+            return;
+        };
+        self.changes.extend(check.drain().flat_map(|(_, v)| v.into_keys()));
         if let Some(fixes) = Arc::make_mut(&mut self.check_fixes).get_mut(&flycheck_id) {
             fixes.clear();
         }
@@ -70,12 +71,6 @@ impl DiagnosticCollection {
         )
     }
 
-    pub(crate) fn clear_native_for(&mut self, file_id: FileId) {
-        self.native_syntax.remove(&file_id);
-        self.native_semantic.remove(&file_id);
-        self.changes.insert(file_id);
-    }
-
     pub(crate) fn clear_check_for_package(
         &mut self,
         flycheck_id: usize,
@@ -84,7 +79,19 @@ impl DiagnosticCollection {
         let Some(check) = self.check.get_mut(&flycheck_id) else {
             return;
         };
-        check.remove(&Some(package_id));
+        let package_id = Some(package_id);
+        if let Some(checks) = check.remove(&package_id) {
+            self.changes.extend(checks.into_keys());
+        }
+        if let Some(fixes) = Arc::make_mut(&mut self.check_fixes).get_mut(&flycheck_id) {
+            fixes.remove(&package_id);
+        }
+    }
+
+    pub(crate) fn clear_native_for(&mut self, file_id: FileId) {
+        self.native_syntax.remove(&file_id);
+        self.native_semantic.remove(&file_id);
+        self.changes.insert(file_id);
     }
 
     pub(crate) fn add_check_diagnostic(
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 a9eb15ce339..53c145f884e 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs
@@ -369,6 +369,7 @@ impl FlycheckActor {
                         tracing::trace!(
                             flycheck_id = self.id,
                             artifact = msg.target.name,
+                            package_id = msg.package_id.repr,
                             "artifact received"
                         );
                         self.report_progress(Progress::DidCheckCrate(msg.target.name));
@@ -380,6 +381,7 @@ impl FlycheckActor {
                         tracing::trace!(
                             flycheck_id = self.id,
                             message = diagnostic.message,
+                            package_id = package_id.as_ref().map(|it| &it.repr),
                             "diagnostic received"
                         );
                         if let Some(package_id) = &package_id {