diff options
| author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-08-06 14:16:24 +0000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-06 14:16:24 +0000 |
| commit | b8800fd85d705bb91c002a3a16dbf6150c7df20b (patch) | |
| tree | ba5ef1aa7a3622972d7e014a84c898b546a24a47 | |
| parent | 40e9c97d61681fb1806f254e6938db5f74c06a05 (diff) | |
| parent | a310d7453643d0038abd2f04d8b6bf600d412d46 (diff) | |
Merge #9801
9801: fix: Don't publish diagnostics in crates.io or sysroot files r=jonas-schievink a=jonas-schievink Fixes https://github.com/rust-analyzer/rust-analyzer/issues/9766 bors r+ Co-authored-by: Jonas Schievink <jonasschievink@gmail.com>
| -rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 62ff922e1ff..13303704723 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -9,7 +9,7 @@ use std::{ use always_assert::always; use crossbeam_channel::{select, Receiver}; use ide::{FileId, PrimeCachesProgress}; -use ide_db::base_db::VfsPath; +use ide_db::base_db::{SourceDatabaseExt, VfsPath}; use lsp_server::{Connection, Notification, Request}; use lsp_types::notification::Notification as _; use vfs::ChangeKind; @@ -454,6 +454,17 @@ impl GlobalState { if let Some(diagnostic_changes) = self.diagnostics.take_changes() { for file_id in diagnostic_changes { + let db = self.analysis_host.raw_database(); + let source_root = db.file_source_root(file_id); + if db.source_root(source_root).is_library { + // Only publish diagnostics for files in the workspace, not from crates.io deps + // or the sysroot. + // While theoretically these should never have errors, we have quite a few false + // positives particularly in the stdlib, and those diagnostics would stay around + // forever if we emitted them here. + continue; + } + let url = file_id_to_url(&self.vfs.read().0, file_id); let diagnostics = self.diagnostics.diagnostics_for(file_id).cloned().collect(); let version = from_proto::vfs_path(&url) |
