aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt47
-rw-r--r--crates/rust-analyzer/src/diagnostics/to_proto.rs6
2 files changed, 48 insertions, 5 deletions
diff --git a/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt b/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt
index 7576097b3..ce80476fb 100644
--- a/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt
+++ b/crates/rust-analyzer/src/diagnostics/test_data/clippy_pass_by_ref.txt
@@ -266,6 +266,51 @@
266 tags: None, 266 tags: None,
267 data: None, 267 data: None,
268 }, 268 },
269 fixes: [], 269 fixes: [
270 CodeAction {
271 title: "consider passing by value instead",
272 group: None,
273 kind: Some(
274 CodeActionKind(
275 "quickfix",
276 ),
277 ),
278 edit: Some(
279 SnippetWorkspaceEdit {
280 changes: Some(
281 {
282 Url {
283 scheme: "file",
284 host: None,
285 port: None,
286 path: "/test/compiler/mir/tagset.rs",
287 query: None,
288 fragment: None,
289 }: [
290 TextEdit {
291 range: Range {
292 start: Position {
293 line: 41,
294 character: 23,
295 },
296 end: Position {
297 line: 41,
298 character: 28,
299 },
300 },
301 new_text: "self",
302 },
303 ],
304 },
305 ),
306 document_changes: None,
307 },
308 ),
309 is_preferred: Some(
310 true,
311 ),
312 data: None,
313 },
314 ],
270 }, 315 },
271] 316]
diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs
index 757899484..0ed87fe3e 100644
--- a/crates/rust-analyzer/src/diagnostics/to_proto.rs
+++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs
@@ -2,7 +2,7 @@
2//! `cargo check` json format to the LSP diagnostic format. 2//! `cargo check` json format to the LSP diagnostic format.
3use std::{collections::HashMap, path::Path}; 3use std::{collections::HashMap, path::Path};
4 4
5use flycheck::{Applicability, DiagnosticLevel, DiagnosticSpan}; 5use flycheck::{DiagnosticLevel, DiagnosticSpan};
6use stdx::format_to; 6use stdx::format_to;
7 7
8use crate::{lsp_ext, to_proto::url_from_abs_path}; 8use crate::{lsp_ext, to_proto::url_from_abs_path};
@@ -97,9 +97,7 @@ fn map_rust_child_diagnostic(
97 97
98 let mut edit_map: HashMap<lsp_types::Url, Vec<lsp_types::TextEdit>> = HashMap::new(); 98 let mut edit_map: HashMap<lsp_types::Url, Vec<lsp_types::TextEdit>> = HashMap::new();
99 for &span in &spans { 99 for &span in &spans {
100 if let (Some(Applicability::MachineApplicable), Some(suggested_replacement)) = 100 if let Some(suggested_replacement) = &span.suggested_replacement {
101 (&span.suggestion_applicability, &span.suggested_replacement)
102 {
103 let location = location(workspace_root, span); 101 let location = location(workspace_root, span);
104 let edit = lsp_types::TextEdit::new(location.range, suggested_replacement.clone()); 102 let edit = lsp_types::TextEdit::new(location.range, suggested_replacement.clone());
105 edit_map.entry(location.uri).or_default().push(edit); 103 edit_map.entry(location.uri).or_default().push(edit);