Skip to content

Commit

Permalink
Adress new clippy::large_enum_variant diagnostics
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Aug 17, 2024
1 parent 07c1b83 commit 1013bf3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
8 changes: 5 additions & 3 deletions crates/rust-analyzer/src/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl DiagnosticCollection {
flycheck_id: usize,
file_id: FileId,
diagnostic: lsp_types::Diagnostic,
fix: Option<Fix>,
fix: Option<Box<Fix>>,
) {
let diagnostics = self.check.entry(flycheck_id).or_default().entry(file_id).or_default();
for existing_diagnostic in diagnostics.iter() {
Expand All @@ -84,8 +84,10 @@ impl DiagnosticCollection {
}
}

let check_fixes = Arc::make_mut(&mut self.check_fixes);
check_fixes.entry(flycheck_id).or_default().entry(file_id).or_default().extend(fix);
if let Some(fix) = fix {
let check_fixes = Arc::make_mut(&mut self.check_fixes);
check_fixes.entry(flycheck_id).or_default().entry(file_id).or_default().push(*fix);
}
diagnostics.push(diagnostic);
self.changes.insert(file_id);
}
Expand Down
8 changes: 4 additions & 4 deletions crates/rust-analyzer/src/diagnostics/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ fn resolve_path(

struct SubDiagnostic {
related: lsp_types::DiagnosticRelatedInformation,
suggested_fix: Option<Fix>,
suggested_fix: Option<Box<Fix>>,
}

enum MappedRustChildDiagnostic {
Expand Down Expand Up @@ -241,7 +241,7 @@ fn map_rust_child_diagnostic(
location: location(config, workspace_root, spans[0], snap),
message: message.clone(),
},
suggested_fix: Some(Fix {
suggested_fix: Some(Box::new(Fix {
ranges: spans
.iter()
.map(|&span| location(config, workspace_root, span, snap).range)
Expand All @@ -260,7 +260,7 @@ fn map_rust_child_diagnostic(
data: None,
command: None,
},
}),
})),
})
}
}
Expand All @@ -269,7 +269,7 @@ fn map_rust_child_diagnostic(
pub(crate) struct MappedRustDiagnostic {
pub(crate) url: lsp_types::Url,
pub(crate) diagnostic: lsp_types::Diagnostic,
pub(crate) fix: Option<Fix>,
pub(crate) fix: Option<Box<Fix>>,
}

/// Converts a Rust root diagnostic to LSP form
Expand Down
1 change: 1 addition & 0 deletions crates/rust-analyzer/src/flycheck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ struct FlycheckActor {
status: FlycheckStatus,
}

#[allow(clippy::large_enum_variant)]
enum Event {
RequestStateChange(StateChange),
CheckEvent(Option<CargoCheckMessage>),
Expand Down

0 comments on commit 1013bf3

Please sign in to comment.