@@ -323,17 +323,6 @@ impl GlobalState {
323
323
324
324
if let Some ( diagnostic_changes) = self . diagnostics . take_changes ( ) {
325
325
for file_id in diagnostic_changes {
326
- let db = self . analysis_host . raw_database ( ) ;
327
- let source_root = db. file_source_root ( file_id) ;
328
- if db. source_root ( source_root) . is_library {
329
- // Only publish diagnostics for files in the workspace, not from crates.io deps
330
- // or the sysroot.
331
- // While theoretically these should never have errors, we have quite a few false
332
- // positives particularly in the stdlib, and those diagnostics would stay around
333
- // forever if we emitted them here.
334
- continue ;
335
- }
336
-
337
326
let uri = file_id_to_url ( & self . vfs . read ( ) . 0 , file_id) ;
338
327
let mut diagnostics =
339
328
self . diagnostics . diagnostics_for ( file_id) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
@@ -972,10 +961,20 @@ impl GlobalState {
972
961
}
973
962
974
963
fn update_diagnostics ( & mut self ) {
964
+ let db = self . analysis_host . raw_database ( ) ;
975
965
let subscriptions = self
976
966
. mem_docs
977
967
. iter ( )
978
968
. map ( |path| self . vfs . read ( ) . 0 . file_id ( path) . unwrap ( ) )
969
+ . filter ( |& file_id| {
970
+ let source_root = db. file_source_root ( file_id) ;
971
+ // Only publish diagnostics for files in the workspace, not from crates.io deps
972
+ // or the sysroot.
973
+ // While theoretically these should never have errors, we have quite a few false
974
+ // positives particularly in the stdlib, and those diagnostics would stay around
975
+ // forever if we emitted them here.
976
+ !db. source_root ( source_root) . is_library
977
+ } )
979
978
. collect :: < Vec < _ > > ( ) ;
980
979
981
980
tracing:: trace!( "updating notifications for {:?}" , subscriptions) ;
0 commit comments