about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorLukas Wirth <lukastw97@gmail.com>2024-08-17 19:18:56 +0200
committerLukas Wirth <lukastw97@gmail.com>2024-08-17 19:18:56 +0200
commit324cf839bdedf80183d4e0c0d6b7ddf970eb8a2d (patch)
tree6d63cad124332d1b2bccd2d6f16cbad310bdb0a6 /src
parentd0ce97f41da59a49104bb252eab0ff5cf9ec613d (diff)
downloadrust-324cf839bdedf80183d4e0c0d6b7ddf970eb8a2d.tar.gz
rust-324cf839bdedf80183d4e0c0d6b7ddf970eb8a2d.zip
Adress new clippy::large_enum_variant diagnostics
Diffstat (limited to 'src')
-rw-r--r--src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs8
-rw-r--r--src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics/to_proto.rs8
-rw-r--r--src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs1
3 files changed, 10 insertions, 7 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs
index 034c49c3d5c..5f2871ac992 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics.rs
@@ -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() {
@@ -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);
     }
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics/to_proto.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics/to_proto.rs
index 208a70bc02a..e330cfc3cfd 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics/to_proto.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/diagnostics/to_proto.rs
@@ -170,7 +170,7 @@ fn resolve_path(
 
 struct SubDiagnostic {
     related: lsp_types::DiagnosticRelatedInformation,
-    suggested_fix: Option<Fix>,
+    suggested_fix: Option<Box<Fix>>,
 }
 
 enum MappedRustChildDiagnostic {
@@ -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)
@@ -260,7 +260,7 @@ fn map_rust_child_diagnostic(
                     data: None,
                     command: None,
                 },
-            }),
+            })),
         })
     }
 }
@@ -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
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs
index 8f2e7d1ca26..443f52c6dd3 100644
--- a/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs
+++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/flycheck.rs
@@ -218,6 +218,7 @@ struct FlycheckActor {
     status: FlycheckStatus,
 }
 
+#[allow(clippy::large_enum_variant)]
 enum Event {
     RequestStateChange(StateChange),
     CheckEvent(Option<CargoCheckMessage>),