Skip to content

Commit 5410ace

Browse files
committed
fix: Clear native diagnostics for files when they are deleted
1 parent f02c915 commit 5410ace

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

crates/rust-analyzer/src/diagnostics.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,11 @@ impl DiagnosticCollection {
4040
self.changes.extend(self.check.drain().map(|(key, _value)| key))
4141
}
4242

43+
pub(crate) fn clear_native_for(&mut self, file_id: FileId) {
44+
self.native.remove(&file_id);
45+
self.changes.insert(file_id);
46+
}
47+
4348
pub(crate) fn add_check_diagnostic(
4449
&mut self,
4550
file_id: FileId,

crates/rust-analyzer/src/global_state.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,10 @@ impl GlobalState {
201201
}
202202
}
203203

204+
if !file.exists() {
205+
self.diagnostics.clear_native_for(file.file_id);
206+
}
207+
204208
let text = if file.exists() {
205209
let bytes = vfs.file_contents(file.file_id).to_vec();
206210
String::from_utf8(bytes).ok().and_then(|text| {

0 commit comments

Comments
 (0)