Skip to content

Commit

Permalink
Auto merge of rust-lang#12383 - Veykril:diag, r=Veykril
Browse files Browse the repository at this point in the history
fix: Clear native diagnostics for files when they are deleted

Fixes rust-lang/rust-analyzer#7004
  • Loading branch information
bors committed May 25, 2022
2 parents 3fe137a + 5410ace commit c13f04d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/rust-analyzer/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 4 additions & 0 deletions crates/rust-analyzer/src/global_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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| {
Expand Down

0 comments on commit c13f04d

Please sign in to comment.