From 9d0196a4914eb66003f21309ff7018d3e0f237a6 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Thu, 9 Jul 2020 15:35:52 +0200 Subject: Simplify --- ...gnostics__to_proto__tests__snap_clippy_pass_by_ref.snap | 14 +------------- ...tics__to_proto__tests__snap_handles_macro_location.snap | 14 +------------- ...ostics__to_proto__tests__snap_macro_compiler_error.snap | 14 +------------- ..._diagnostics__to_proto__tests__snap_multi_line_fix.snap | 14 +------------- ...oto__tests__snap_rustc_incompatible_type_for_trait.snap | 14 +------------- ...stics__to_proto__tests__snap_rustc_mismatched_type.snap | 14 +------------- ...stics__to_proto__tests__snap_rustc_unused_variable.snap | 14 +------------- ...o_proto__tests__snap_rustc_unused_variable_as_hint.snap | 14 +------------- ...o_proto__tests__snap_rustc_unused_variable_as_info.snap | 14 +------------- ...roto__tests__snap_rustc_wrong_number_of_parameters.snap | 14 +------------- crates/rust-analyzer/src/diagnostics/to_proto.rs | 4 ++-- crates/rust-analyzer/src/main_loop.rs | 2 +- 12 files changed, 13 insertions(+), 133 deletions(-) diff --git a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_clippy_pass_by_ref.snap b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_clippy_pass_by_ref.snap index d7f9ec049..578b1e128 100644 --- a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_clippy_pass_by_ref.snap +++ b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_clippy_pass_by_ref.snap @@ -4,19 +4,7 @@ expression: diag --- [ MappedRustDiagnostic { - location: Location { - uri: "file:///test/compiler/mir/tagset.rs", - range: Range { - start: Position { - line: 41, - character: 23, - }, - end: Position { - line: 41, - character: 28, - }, - }, - }, + url: "file:///test/compiler/mir/tagset.rs", diagnostic: Diagnostic { range: Range { start: Position { diff --git a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_handles_macro_location.snap b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_handles_macro_location.snap index a59faf254..577cf4b2d 100644 --- a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_handles_macro_location.snap +++ b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_handles_macro_location.snap @@ -4,19 +4,7 @@ expression: diag --- [ MappedRustDiagnostic { - location: Location { - uri: "file:///test/src/main.rs", - range: Range { - start: Position { - line: 1, - character: 4, - }, - end: Position { - line: 1, - character: 26, - }, - }, - }, + url: "file:///test/src/main.rs", diagnostic: Diagnostic { range: Range { start: Position { diff --git a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_macro_compiler_error.snap b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_macro_compiler_error.snap index 3c78e7f36..22bd23a88 100644 --- a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_macro_compiler_error.snap +++ b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_macro_compiler_error.snap @@ -4,19 +4,7 @@ expression: diag --- [ MappedRustDiagnostic { - location: Location { - uri: "file:///test/crates/ra_hir_def/src/data.rs", - range: Range { - start: Position { - line: 79, - character: 15, - }, - end: Position { - line: 79, - character: 41, - }, - }, - }, + url: "file:///test/crates/ra_hir_def/src/data.rs", diagnostic: Diagnostic { range: Range { start: Position { diff --git a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_multi_line_fix.snap b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_multi_line_fix.snap index 272057b47..1a0ac4f42 100644 --- a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_multi_line_fix.snap +++ b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_multi_line_fix.snap @@ -4,19 +4,7 @@ expression: diag --- [ MappedRustDiagnostic { - location: Location { - uri: "file:///test/src/main.rs", - range: Range { - start: Position { - line: 3, - character: 4, - }, - end: Position { - line: 3, - character: 5, - }, - }, - }, + url: "file:///test/src/main.rs", diagnostic: Diagnostic { range: Range { start: Position { diff --git a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_incompatible_type_for_trait.snap b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_incompatible_type_for_trait.snap index 46d0c56d2..cc608dafe 100644 --- a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_incompatible_type_for_trait.snap +++ b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_incompatible_type_for_trait.snap @@ -4,19 +4,7 @@ expression: diag --- [ MappedRustDiagnostic { - location: Location { - uri: "file:///test/compiler/ty/list_iter.rs", - range: Range { - start: Position { - line: 51, - character: 4, - }, - end: Position { - line: 51, - character: 47, - }, - }, - }, + url: "file:///test/compiler/ty/list_iter.rs", diagnostic: Diagnostic { range: Range { start: Position { diff --git a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_mismatched_type.snap b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_mismatched_type.snap index 4182929ba..4d2a8625e 100644 --- a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_mismatched_type.snap +++ b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_mismatched_type.snap @@ -4,19 +4,7 @@ expression: diag --- [ MappedRustDiagnostic { - location: Location { - uri: "file:///test/runtime/compiler_support.rs", - range: Range { - start: Position { - line: 47, - character: 64, - }, - end: Position { - line: 47, - character: 69, - }, - }, - }, + url: "file:///test/runtime/compiler_support.rs", diagnostic: Diagnostic { range: Range { start: Position { diff --git a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable.snap b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable.snap index 9a7972ff5..e35941c76 100644 --- a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable.snap +++ b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable.snap @@ -4,19 +4,7 @@ expression: diag --- [ MappedRustDiagnostic { - location: Location { - uri: "file:///test/driver/subcommand/repl.rs", - range: Range { - start: Position { - line: 290, - character: 8, - }, - end: Position { - line: 290, - character: 11, - }, - }, - }, + url: "file:///test/driver/subcommand/repl.rs", diagnostic: Diagnostic { range: Range { start: Position { diff --git a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable_as_hint.snap b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable_as_hint.snap index f0273315e..b6a7bcf60 100644 --- a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable_as_hint.snap +++ b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable_as_hint.snap @@ -4,19 +4,7 @@ expression: diag --- [ MappedRustDiagnostic { - location: Location { - uri: "file:///test/driver/subcommand/repl.rs", - range: Range { - start: Position { - line: 290, - character: 8, - }, - end: Position { - line: 290, - character: 11, - }, - }, - }, + url: "file:///test/driver/subcommand/repl.rs", diagnostic: Diagnostic { range: Range { start: Position { diff --git a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable_as_info.snap b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable_as_info.snap index 85fd050fd..8c248faf2 100644 --- a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable_as_info.snap +++ b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_unused_variable_as_info.snap @@ -4,19 +4,7 @@ expression: diag --- [ MappedRustDiagnostic { - location: Location { - uri: "file:///test/driver/subcommand/repl.rs", - range: Range { - start: Position { - line: 290, - character: 8, - }, - end: Position { - line: 290, - character: 11, - }, - }, - }, + url: "file:///test/driver/subcommand/repl.rs", diagnostic: Diagnostic { range: Range { start: Position { diff --git a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_wrong_number_of_parameters.snap b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_wrong_number_of_parameters.snap index f6ab05004..3ece40eaf 100644 --- a/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_wrong_number_of_parameters.snap +++ b/crates/rust-analyzer/src/diagnostics/snapshots/rust_analyzer__diagnostics__to_proto__tests__snap_rustc_wrong_number_of_parameters.snap @@ -4,19 +4,7 @@ expression: diag --- [ MappedRustDiagnostic { - location: Location { - uri: "file:///test/compiler/ty/select.rs", - range: Range { - start: Position { - line: 103, - character: 17, - }, - end: Position { - line: 103, - character: 29, - }, - }, - }, + url: "file:///test/compiler/ty/select.rs", diagnostic: Diagnostic { range: Range { start: Position { diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index f3a22885e..ded96c58a 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs @@ -125,7 +125,7 @@ fn map_rust_child_diagnostic( #[derive(Debug)] pub(crate) struct MappedRustDiagnostic { - pub(crate) location: lsp_types::Location, + pub(crate) url: lsp_types::Url, pub(crate) diagnostic: lsp_types::Diagnostic, pub(crate) fixes: Vec, } @@ -246,7 +246,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp( tags: if tags.is_empty() { None } else { Some(tags.clone()) }, }; - MappedRustDiagnostic { location, diagnostic, fixes: fixes.clone() } + MappedRustDiagnostic { url: location.uri, diagnostic, fixes: fixes.clone() } }) .collect() } diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 5900886e7..4e556bd50 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -238,7 +238,7 @@ impl GlobalState { &workspace_root, ); for diag in diagnostics { - match url_to_file_id(&self.vfs.read().0, &diag.location.uri) { + match url_to_file_id(&self.vfs.read().0, &diag.url) { Ok(file_id) => self.diagnostics.add_check_diagnostic( file_id, diag.diagnostic, -- cgit v1.2.3