]> git.lizzy.rs Git - rust.git/commitdiff
fix: Clear native diagnostics for files when they are deleted
authorLukas Wirth <lukastw97@gmail.com>
Wed, 25 May 2022 13:47:41 +0000 (15:47 +0200)
committerLukas Wirth <lukastw97@gmail.com>
Wed, 25 May 2022 13:47:41 +0000 (15:47 +0200)
crates/rust-analyzer/src/diagnostics.rs
crates/rust-analyzer/src/global_state.rs

index 56b3afce98a33a3fc04b6301363f8ec6c2c1ea73..202a01adf71083595ec95da60674003a9df9b576 100644 (file)
@@ -40,6 +40,11 @@ pub(crate) fn clear_check(&mut self) {
         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,
index d2b4fac5dc020bf98a43c545a509e69de50626f4..4af60035a20e0e21c78daa8a1a3d0833dface9d6 100644 (file)
@@ -201,6 +201,10 @@ pub(crate) fn process_changes(&mut self) -> bool {
                     }
                 }
 
+                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| {