Refactor away unnecessary Vec

This commit is contained in:
Brandon 2021-12-04 19:59:05 -08:00
parent 6005ea5440
commit de05c3d406
3 changed files with 7 additions and 7 deletions

View File

@ -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);
}

View File

@ -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),

View File

@ -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!(