Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #18740 from Veykril/push-tntsvtmtlotw
fix: Fix empty check diagnostics not marking files as changed
Lukas Wirth 2024-12-22
parent 2f33e85 · parent 8da08e7 · commit d67b900
-rw-r--r--crates/hir-ty/src/chalk_db.rs11
-rw-r--r--crates/rust-analyzer/src/diagnostics.rs27
-rw-r--r--crates/rust-analyzer/src/flycheck.rs2
3 files changed, 20 insertions, 20 deletions
diff --git a/crates/hir-ty/src/chalk_db.rs b/crates/hir-ty/src/chalk_db.rs
index 53795c0b60..55d0edd5e0 100644
--- a/crates/hir-ty/src/chalk_db.rs
+++ b/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/crates/rust-analyzer/src/diagnostics.rs b/crates/rust-analyzer/src/diagnostics.rs
index e64a15ae04..0b51dd87fe 100644
--- a/crates/rust-analyzer/src/diagnostics.rs
+++ b/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/crates/rust-analyzer/src/flycheck.rs b/crates/rust-analyzer/src/flycheck.rs
index a9eb15ce33..53c145f884 100644
--- a/crates/rust-analyzer/src/flycheck.rs
+++ b/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 {