Skip to content

Commit b6bb1e9

Browse files
committed
Only set machine-applicable rustc diagnostics as preferred
1 parent c4d8cf1 commit b6bb1e9

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,7 @@ fn map_rust_child_diagnostic(
191191

192192
let mut edit_map: HashMap<lsp_types::Url, Vec<lsp_types::TextEdit>> = HashMap::new();
193193
let mut suggested_replacements = Vec::new();
194+
let mut is_preferred = true;
194195
for &span in &spans {
195196
if let Some(suggested_replacement) = &span.suggested_replacement {
196197
if !suggested_replacement.is_empty() {
@@ -209,6 +210,8 @@ fn map_rust_child_diagnostic(
209210
) {
210211
edit_map.entry(location.uri).or_default().push(edit);
211212
}
213+
is_preferred &=
214+
matches!(span.suggestion_applicability, Some(Applicability::MachineApplicable));
212215
}
213216
}
214217

@@ -251,7 +254,7 @@ fn map_rust_child_diagnostic(
251254
document_changes: None,
252255
change_annotations: None,
253256
}),
254-
is_preferred: Some(true),
257+
is_preferred: Some(is_preferred),
255258
data: None,
256259
command: None,
257260
},

0 commit comments

Comments
 (0)