Unnamed repository; edit this file 'description' to name the repository.
fix: Clear native diagnostics for files when they are deleted
Lukas Wirth 2022-05-25
parent f02c915 · commit 5410ace
-rw-r--r--crates/rust-analyzer/src/diagnostics.rs5
-rw-r--r--crates/rust-analyzer/src/global_state.rs4
2 files changed, 9 insertions, 0 deletions
diff --git a/crates/rust-analyzer/src/diagnostics.rs b/crates/rust-analyzer/src/diagnostics.rs
index 56b3afce98..202a01adf7 100644
--- a/crates/rust-analyzer/src/diagnostics.rs
+++ b/crates/rust-analyzer/src/diagnostics.rs
@@ -40,6 +40,11 @@ impl DiagnosticCollection {
self.changes.extend(self.check.drain().map(|(key, _value)| key))
}
+ pub(crate) fn clear_native_for(&mut self, file_id: FileId) {
+ self.native.remove(&file_id);
+ self.changes.insert(file_id);
+ }
+
pub(crate) fn add_check_diagnostic(
&mut self,
file_id: FileId,
diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs
index d2b4fac5dc..4af60035a2 100644
--- a/crates/rust-analyzer/src/global_state.rs
+++ b/crates/rust-analyzer/src/global_state.rs
@@ -201,6 +201,10 @@ impl GlobalState {
}
}
+ if !file.exists() {
+ self.diagnostics.clear_native_for(file.file_id);
+ }
+
let text = if file.exists() {
let bytes = vfs.file_contents(file.file_id).to_vec();
String::from_utf8(bytes).ok().and_then(|text| {