]> git.lizzy.rs Git - rust.git/commitdiff
Only set machine-applicable rustc diagnostics as preferred
authorLukas Wirth <lukastw97@gmail.com>
Tue, 3 Jan 2023 14:46:08 +0000 (15:46 +0100)
committerLukas Wirth <lukastw97@gmail.com>
Tue, 3 Jan 2023 14:46:08 +0000 (15:46 +0100)
crates/rust-analyzer/src/diagnostics/to_proto.rs

index d1ee99af3ec6e5f4a8fa06dd124c9a202b170aed..80be43fe80a46692c3cdb8a56c00525efe3c88e4 100644 (file)
@@ -191,6 +191,7 @@ fn map_rust_child_diagnostic(
 
     let mut edit_map: HashMap<lsp_types::Url, Vec<lsp_types::TextEdit>> = HashMap::new();
     let mut suggested_replacements = Vec::new();
+    let mut is_preferred = true;
     for &span in &spans {
         if let Some(suggested_replacement) = &span.suggested_replacement {
             if !suggested_replacement.is_empty() {
@@ -209,6 +210,8 @@ fn map_rust_child_diagnostic(
             ) {
                 edit_map.entry(location.uri).or_default().push(edit);
             }
+            is_preferred &=
+                matches!(span.suggestion_applicability, Some(Applicability::MachineApplicable));
         }
     }
 
@@ -251,7 +254,7 @@ fn map_rust_child_diagnostic(
                         document_changes: None,
                         change_annotations: None,
                     }),
-                    is_preferred: Some(true),
+                    is_preferred: Some(is_preferred),
                     data: None,
                     command: None,
                 },