Skip to content

Commit 84b7c8b

Browse files
authored
Merge pull request rust-lang#18740 from Veykril/push-tntsvtmtlotw
fix: Fix empty check diagnostics not marking files as changed
2 parents 3613526 + 2a977e0 commit 84b7c8b

File tree

3 files changed

+20
-20
lines changed

3 files changed

+20
-20
lines changed

src/tools/rust-analyzer/crates/hir-ty/src/chalk_db.rs

+1-10
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ use hir_def::{
2222

2323
use crate::{
2424
db::{HirDatabase, InternedCoroutine},
25-
display::HirDisplay,
2625
from_assoc_type_id, from_chalk_trait_id, from_foreign_def_id,
2726
generics::generics,
2827
make_binders, make_single_type_binders,
@@ -823,13 +822,12 @@ pub(crate) fn impl_datum_query(
823822
let _p = tracing::info_span!("impl_datum_query").entered();
824823
debug!("impl_datum {:?}", impl_id);
825824
let impl_: hir_def::ImplId = from_chalk(db, impl_id);
826-
impl_def_datum(db, krate, impl_id, impl_)
825+
impl_def_datum(db, krate, impl_)
827826
}
828827

829828
fn impl_def_datum(
830829
db: &dyn HirDatabase,
831830
krate: CrateId,
832-
chalk_id: ImplId,
833831
impl_id: hir_def::ImplId,
834832
) -> Arc<ImplDatum> {
835833
let trait_ref = db
@@ -850,13 +848,6 @@ fn impl_def_datum(
850848
};
851849
let where_clauses = convert_where_clauses(db, impl_id.into(), &bound_vars);
852850
let negative = impl_data.is_negative;
853-
debug!(
854-
"impl {:?}: {}{} where {:?}",
855-
chalk_id,
856-
if negative { "!" } else { "" },
857-
trait_ref.display(db, db.crate_graph()[krate].edition),
858-
where_clauses
859-
);
860851

861852
let polarity = if negative { rust_ir::Polarity::Negative } else { rust_ir::Polarity::Positive };
862853

src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs

+17-10
Original file line numberDiff line numberDiff line change
@@ -55,9 +55,10 @@ pub(crate) struct Fix {
5555

5656
impl DiagnosticCollection {
5757
pub(crate) fn clear_check(&mut self, flycheck_id: usize) {
58-
if let Some(it) = self.check.get_mut(&flycheck_id) {
59-
it.clear();
60-
}
58+
let Some(check) = self.check.get_mut(&flycheck_id) else {
59+
return;
60+
};
61+
self.changes.extend(check.drain().flat_map(|(_, v)| v.into_keys()));
6162
if let Some(fixes) = Arc::make_mut(&mut self.check_fixes).get_mut(&flycheck_id) {
6263
fixes.clear();
6364
}
@@ -70,12 +71,6 @@ impl DiagnosticCollection {
7071
)
7172
}
7273

73-
pub(crate) fn clear_native_for(&mut self, file_id: FileId) {
74-
self.native_syntax.remove(&file_id);
75-
self.native_semantic.remove(&file_id);
76-
self.changes.insert(file_id);
77-
}
78-
7974
pub(crate) fn clear_check_for_package(
8075
&mut self,
8176
flycheck_id: usize,
@@ -84,7 +79,19 @@ impl DiagnosticCollection {
8479
let Some(check) = self.check.get_mut(&flycheck_id) else {
8580
return;
8681
};
87-
check.remove(&Some(package_id));
82+
let package_id = Some(package_id);
83+
if let Some(checks) = check.remove(&package_id) {
84+
self.changes.extend(checks.into_keys());
85+
}
86+
if let Some(fixes) = Arc::make_mut(&mut self.check_fixes).get_mut(&flycheck_id) {
87+
fixes.remove(&package_id);
88+
}
89+
}
90+
91+
pub(crate) fn clear_native_for(&mut self, file_id: FileId) {
92+
self.native_syntax.remove(&file_id);
93+
self.native_semantic.remove(&file_id);
94+
self.changes.insert(file_id);
8895
}
8996

9097
pub(crate) fn add_check_diagnostic(

src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs

+2
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,7 @@ impl FlycheckActor {
369369
tracing::trace!(
370370
flycheck_id = self.id,
371371
artifact = msg.target.name,
372+
package_id = msg.package_id.repr,
372373
"artifact received"
373374
);
374375
self.report_progress(Progress::DidCheckCrate(msg.target.name));
@@ -380,6 +381,7 @@ impl FlycheckActor {
380381
tracing::trace!(
381382
flycheck_id = self.id,
382383
message = diagnostic.message,
384+
package_id = package_id.as_ref().map(|it| &it.repr),
383385
"diagnostic received"
384386
);
385387
if let Some(package_id) = &package_id {

0 commit comments

Comments
 (0)