Skip to content

Commit

Permalink
Merge pull request #18740 from Veykril/push-tntsvtmtlotw
Browse files Browse the repository at this point in the history
fix: Fix empty check diagnostics not marking files as changed
  • Loading branch information
Veykril authored Dec 22, 2024
2 parents 2f33e85 + 8da08e7 commit d67b900
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 20 deletions.
11 changes: 1 addition & 10 deletions crates/hir-ty/src/chalk_db.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand All @@ -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 };

Expand Down
27 changes: 17 additions & 10 deletions crates/rust-analyzer/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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,
Expand All @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions crates/rust-analyzer/src/flycheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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 {
Expand Down

0 comments on commit d67b900

Please sign in to comment.