Skip to content

Commit 324cf83

Browse files
committed
Adress new clippy::large_enum_variant diagnostics
1 parent d0ce97f commit 324cf83

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl DiagnosticCollection {
7575
flycheck_id: usize,
7676
file_id: FileId,
7777
diagnostic: lsp_types::Diagnostic,
78-
fix: Option<Fix>,
78+
fix: Option<Box<Fix>>,
7979
) {
8080
let diagnostics = self.check.entry(flycheck_id).or_default().entry(file_id).or_default();
8181
for existing_diagnostic in diagnostics.iter() {
@@ -84,8 +84,10 @@ impl DiagnosticCollection {
8484
}
8585
}
8686

87-
let check_fixes = Arc::make_mut(&mut self.check_fixes);
88-
check_fixes.entry(flycheck_id).or_default().entry(file_id).or_default().extend(fix);
87+
if let Some(fix) = fix {
88+
let check_fixes = Arc::make_mut(&mut self.check_fixes);
89+
check_fixes.entry(flycheck_id).or_default().entry(file_id).or_default().push(*fix);
90+
}
8991
diagnostics.push(diagnostic);
9092
self.changes.insert(file_id);
9193
}

src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics/to_proto.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ fn resolve_path(
170170

171171
struct SubDiagnostic {
172172
related: lsp_types::DiagnosticRelatedInformation,
173-
suggested_fix: Option<Fix>,
173+
suggested_fix: Option<Box<Fix>>,
174174
}
175175

176176
enum MappedRustChildDiagnostic {
@@ -241,7 +241,7 @@ fn map_rust_child_diagnostic(
241241
location: location(config, workspace_root, spans[0], snap),
242242
message: message.clone(),
243243
},
244-
suggested_fix: Some(Fix {
244+
suggested_fix: Some(Box::new(Fix {
245245
ranges: spans
246246
.iter()
247247
.map(|&span| location(config, workspace_root, span, snap).range)
@@ -260,7 +260,7 @@ fn map_rust_child_diagnostic(
260260
data: None,
261261
command: None,
262262
},
263-
}),
263+
})),
264264
})
265265
}
266266
}
@@ -269,7 +269,7 @@ fn map_rust_child_diagnostic(
269269
pub(crate) struct MappedRustDiagnostic {
270270
pub(crate) url: lsp_types::Url,
271271
pub(crate) diagnostic: lsp_types::Diagnostic,
272-
pub(crate) fix: Option<Fix>,
272+
pub(crate) fix: Option<Box<Fix>>,
273273
}
274274

275275
/// Converts a Rust root diagnostic to LSP form

src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,7 @@ struct FlycheckActor {
218218
status: FlycheckStatus,
219219
}
220220

221+
#[allow(clippy::large_enum_variant)]
221222
enum Event {
222223
RequestStateChange(StateChange),
223224
CheckEvent(Option<CargoCheckMessage>),

0 commit comments

Comments
 (0)