@@ -323,17 +323,6 @@ impl GlobalState {
323323
324324 if let Some ( diagnostic_changes) = self . diagnostics . take_changes ( ) {
325325 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-
337326 let uri = file_id_to_url ( & self . vfs . read ( ) . 0 , file_id) ;
338327 let mut diagnostics =
339328 self . diagnostics . diagnostics_for ( file_id) . cloned ( ) . collect :: < Vec < _ > > ( ) ;
@@ -972,10 +961,20 @@ impl GlobalState {
972961 }
973962
974963 fn update_diagnostics ( & mut self ) {
964+ let db = self . analysis_host . raw_database ( ) ;
975965 let subscriptions = self
976966 . mem_docs
977967 . iter ( )
978968 . 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+ } )
979978 . collect :: < Vec < _ > > ( ) ;
980979
981980 tracing:: trace!( "updating notifications for {:?}" , subscriptions) ;
0 commit comments