diff options
| author | Brandon <brandondong604@hotmail.com> | 2021-12-04 19:59:05 -0800 |
|---|---|---|
| committer | Brandon <brandondong604@hotmail.com> | 2021-12-04 19:59:05 -0800 |
| commit | de05c3d406fb91dea736769c91cbc35f24abf761 (patch) | |
| tree | e0bc4d9d95042bcdcac7cd46ac20e82139c486d2 | |
| parent | 6005ea544028042b552e3d6d6a6386b2e5eb9159 (diff) | |
| download | rust-de05c3d406fb91dea736769c91cbc35f24abf761.tar.gz rust-de05c3d406fb91dea736769c91cbc35f24abf761.zip | |
Refactor away unnecessary Vec
| -rw-r--r-- | crates/rust-analyzer/src/diagnostics.rs | 4 | ||||
| -rw-r--r-- | crates/rust-analyzer/src/diagnostics/to_proto.rs | 8 | ||||
| -rw-r--r-- | crates/rust-analyzer/src/main_loop.rs | 2 |
3 files changed, 7 insertions, 7 deletions
diff --git a/crates/rust-analyzer/src/diagnostics.rs b/crates/rust-analyzer/src/diagnostics.rs index 2f63c26ce51..c0dab458893 100644 --- a/crates/rust-analyzer/src/diagnostics.rs +++ b/crates/rust-analyzer/src/diagnostics.rs @@ -43,7 +43,7 @@ impl DiagnosticCollection { &mut self, file_id: FileId, diagnostic: lsp_types::Diagnostic, - fixes: Vec<lsp_ext::CodeAction>, + fix: Option<lsp_ext::CodeAction>, ) { let diagnostics = self.check.entry(file_id).or_default(); for existing_diagnostic in diagnostics.iter() { @@ -56,7 +56,7 @@ impl DiagnosticCollection { check_fixes .entry(file_id) .or_default() - .extend(fixes.into_iter().map(|action| Fix { range: diagnostic.range, action })); + .extend(fix.into_iter().map(|action| Fix { range: diagnostic.range, action })); diagnostics.push(diagnostic); self.changes.insert(file_id); } diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 4739cabae55..48af9c186dc 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs @@ -192,7 +192,7 @@ fn map_rust_child_diagnostic( pub(crate) struct MappedRustDiagnostic { pub(crate) url: lsp_types::Url, pub(crate) diagnostic: lsp_types::Diagnostic, - pub(crate) fixes: Vec<lsp_ext::CodeAction>, + pub(crate) fix: Option<lsp_ext::CodeAction>, } /// Converts a Rust root diagnostic to LSP form @@ -349,7 +349,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp( diagnostics.push(MappedRustDiagnostic { url: secondary_location.uri, diagnostic, - fixes: Vec::new(), + fix: None, }); } @@ -378,7 +378,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp( tags: if tags.is_empty() { None } else { Some(tags.clone()) }, data: None, }, - fixes: Vec::new(), + fix: None, }); // Emit hint-level diagnostics for all `related_information` entries such as "help"s. @@ -395,7 +395,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp( } diagnostics.push(MappedRustDiagnostic { url: sub.related.location.uri.clone(), - fixes: sub.suggested_fix.iter().cloned().collect(), + fix: sub.suggested_fix.clone(), diagnostic: lsp_types::Diagnostic { range: sub.related.location.range, severity: Some(lsp_types::DiagnosticSeverity::Hint), diff --git a/crates/rust-analyzer/src/main_loop.rs b/crates/rust-analyzer/src/main_loop.rs index 0c48b22bdba..c05a97eeed7 100644 --- a/crates/rust-analyzer/src/main_loop.rs +++ b/crates/rust-analyzer/src/main_loop.rs @@ -370,7 +370,7 @@ impl GlobalState { Ok(file_id) => self.diagnostics.add_check_diagnostic( file_id, diag.diagnostic, - diag.fixes, + diag.fix, ), Err(err) => { tracing::error!( |
