diff --git a/Cargo.lock b/Cargo.lock index 31fe89cdc03..f94cea81438 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1376,7 +1376,6 @@ name = "rust-analyzer" version = "0.1.0" dependencies = [ "anyhow", - "cargo_metadata", "crossbeam-channel", "env_logger", "globset", diff --git a/crates/ra_flycheck/src/lib.rs b/crates/ra_flycheck/src/lib.rs index 178485c9ee5..541179920ba 100644 --- a/crates/ra_flycheck/src/lib.rs +++ b/crates/ra_flycheck/src/lib.rs @@ -12,6 +12,11 @@ use std::{ use cargo_metadata::Message; use crossbeam_channel::{never, select, unbounded, Receiver, RecvError, Sender}; +pub use cargo_metadata::diagnostic::{ + Applicability, Diagnostic, DiagnosticLevel, DiagnosticSpan, + DiagnosticSpanMacroExpansion, +}; + #[derive(Clone, Debug, PartialEq, Eq)] pub enum FlycheckConfig { CargoCommand { command: String, all_targets: bool, all_features: bool, extra_args: Vec }, @@ -52,7 +57,7 @@ pub enum CheckTask { ClearDiagnostics, /// Request adding a diagnostic with fixes included to a file - AddDiagnostic { workspace_root: PathBuf, diagnostic: cargo_metadata::diagnostic::Diagnostic }, + AddDiagnostic { workspace_root: PathBuf, diagnostic: Diagnostic }, /// Request check progress notification to client Status(Status), @@ -239,12 +244,6 @@ impl FlycheckThread { } } -// #[derive(Debug)] -// pub struct DiagnosticWithFixes { -// diagnostic: Diagnostic, -// fixes: Vec, -// } - enum CheckEvent { Begin, Msg(cargo_metadata::Message), diff --git a/crates/rust-analyzer/Cargo.toml b/crates/rust-analyzer/Cargo.toml index 21e70559719..9b2d29b1d57 100644 --- a/crates/rust-analyzer/Cargo.toml +++ b/crates/rust-analyzer/Cargo.toml @@ -29,7 +29,6 @@ rustc-hash = "1.1.0" serde = { version = "1.0.106", features = ["derive"] } serde_json = "1.0.48" threadpool = "1.7.1" -cargo_metadata = "0.10.0" stdx = { path = "../stdx" } diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 0c810859128..5c8d86eb5e9 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs @@ -1,13 +1,5 @@ //! This module provides the functionality needed to convert diagnostics from //! `cargo check` json format to the LSP diagnostic format. -use cargo_metadata::diagnostic::{ - Applicability, Diagnostic as RustDiagnostic, DiagnosticLevel, DiagnosticSpan, - DiagnosticSpanMacroExpansion, -}; -use lsp_types::{ - CodeAction, Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity, DiagnosticTag, - Location, NumberOrString, Position, Range, TextEdit, Url, WorkspaceEdit, -}; use std::{ collections::HashMap, fmt::Write, @@ -15,6 +7,12 @@ use std::{ str::FromStr, }; +use lsp_types::{ + CodeAction, Diagnostic, DiagnosticRelatedInformation, DiagnosticSeverity, DiagnosticTag, + Location, NumberOrString, Position, Range, TextEdit, Url, WorkspaceEdit, +}; +use ra_flycheck::{Applicability, DiagnosticLevel, DiagnosticSpan, DiagnosticSpanMacroExpansion}; + /// Converts a Rust level string to a LSP severity fn map_level_to_severity(val: DiagnosticLevel) -> Option { match val { @@ -91,7 +89,7 @@ fn map_secondary_span_to_related( } /// Determines if diagnostic is related to unused code -fn is_unused_or_unnecessary(rd: &RustDiagnostic) -> bool { +fn is_unused_or_unnecessary(rd: &ra_flycheck::Diagnostic) -> bool { if let Some(code) = &rd.code { match code.code.as_str() { "dead_code" | "unknown_lints" | "unreachable_code" | "unused_attributes" @@ -122,7 +120,7 @@ enum MappedRustChildDiagnostic { } fn map_rust_child_diagnostic( - rd: &RustDiagnostic, + rd: &ra_flycheck::Diagnostic, workspace_root: &PathBuf, ) -> MappedRustChildDiagnostic { let spans: Vec<&DiagnosticSpan> = rd.spans.iter().filter(|s| s.is_primary).collect(); @@ -179,7 +177,7 @@ pub(crate) struct MappedRustDiagnostic { /// /// If the diagnostic has no primary span this will return `None` pub(crate) fn map_rust_diagnostic_to_lsp( - rd: &RustDiagnostic, + rd: &ra_flycheck::Diagnostic, workspace_root: &PathBuf, ) -> Vec { let primary_spans: Vec<&DiagnosticSpan> = rd.spans.iter().filter(|s| s.is_primary).collect();