mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-03 15:15:24 +00:00
Auto merge of #13887 - Veykril:rustc-diag-preferred, r=Veykril
Only set machine-applicable rustc diagnostics as preferred If they aren't machine applicable, then they might not be what the user wants, disrupting the workflow. Example being:  Prior to the PR this the diagnostic quickfix was at the top, but usually isn't what the user wants.
This commit is contained in:
commit
a97c71f92d
1 changed files with 4 additions and 1 deletions
|
@ -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 edit_map: HashMap<lsp_types::Url, Vec<lsp_types::TextEdit>> = HashMap::new();
|
||||||
let mut suggested_replacements = Vec::new();
|
let mut suggested_replacements = Vec::new();
|
||||||
|
let mut is_preferred = true;
|
||||||
for &span in &spans {
|
for &span in &spans {
|
||||||
if let Some(suggested_replacement) = &span.suggested_replacement {
|
if let Some(suggested_replacement) = &span.suggested_replacement {
|
||||||
if !suggested_replacement.is_empty() {
|
if !suggested_replacement.is_empty() {
|
||||||
|
@ -209,6 +210,8 @@ fn map_rust_child_diagnostic(
|
||||||
) {
|
) {
|
||||||
edit_map.entry(location.uri).or_default().push(edit);
|
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,
|
document_changes: None,
|
||||||
change_annotations: None,
|
change_annotations: None,
|
||||||
}),
|
}),
|
||||||
is_preferred: Some(true),
|
is_preferred: Some(is_preferred),
|
||||||
data: None,
|
data: None,
|
||||||
command: None,
|
command: None,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue