mirror of
https://github.com/rust-lang/rust-analyzer
synced 2025-01-14 14:13:58 +00:00
Auto merge of #12809 - lnicola:empty-diagnostics, r=lnicola
fix: Work around Code bug with empty diagnostics Closes #11404
This commit is contained in:
commit
88515b981d
3 changed files with 18 additions and 8 deletions
|
@ -462,11 +462,6 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
|
||||||
message: "original diagnostic".to_string(),
|
message: "original diagnostic".to_string(),
|
||||||
};
|
};
|
||||||
for sub in &subdiagnostics {
|
for sub in &subdiagnostics {
|
||||||
let mut message = sub.related.message.clone();
|
|
||||||
// Change empty message to " ", as they greatly confuse VS Code.
|
|
||||||
if message.is_empty() {
|
|
||||||
message = String::from(" ");
|
|
||||||
}
|
|
||||||
diagnostics.push(MappedRustDiagnostic {
|
diagnostics.push(MappedRustDiagnostic {
|
||||||
url: sub.related.location.uri.clone(),
|
url: sub.related.location.uri.clone(),
|
||||||
fix: sub.suggested_fix.clone(),
|
fix: sub.suggested_fix.clone(),
|
||||||
|
@ -476,7 +471,7 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
|
||||||
code: code.clone().map(lsp_types::NumberOrString::String),
|
code: code.clone().map(lsp_types::NumberOrString::String),
|
||||||
code_description: code_description.clone(),
|
code_description: code_description.clone(),
|
||||||
source: Some(source.clone()),
|
source: Some(source.clone()),
|
||||||
message,
|
message: sub.related.message.clone(),
|
||||||
related_information: Some(vec![back_ref.clone()]),
|
related_information: Some(vec![back_ref.clone()]),
|
||||||
tags: None, // don't apply modifiers again
|
tags: None, // don't apply modifiers again
|
||||||
data: None,
|
data: None,
|
||||||
|
|
|
@ -1318,7 +1318,8 @@ pub(crate) fn publish_diagnostics(
|
||||||
.unwrap(),
|
.unwrap(),
|
||||||
}),
|
}),
|
||||||
source: Some("rust-analyzer".to_string()),
|
source: Some("rust-analyzer".to_string()),
|
||||||
message: d.message,
|
// https://github.com/rust-lang/rust-analyzer/issues/11404
|
||||||
|
message: if !d.message.is_empty() { d.message } else { " ".to_string() },
|
||||||
related_information: None,
|
related_information: None,
|
||||||
tags: if d.unused { Some(vec![DiagnosticTag::UNNECESSARY]) } else { None },
|
tags: if d.unused { Some(vec![DiagnosticTag::UNNECESSARY]) } else { None },
|
||||||
data: None,
|
data: None,
|
||||||
|
|
|
@ -487,7 +487,21 @@ impl GlobalState {
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = file_id_to_url(&self.vfs.read().0, file_id);
|
let url = file_id_to_url(&self.vfs.read().0, file_id);
|
||||||
let diagnostics = self.diagnostics.diagnostics_for(file_id).cloned().collect();
|
let mut diagnostics =
|
||||||
|
self.diagnostics.diagnostics_for(file_id).cloned().collect::<Vec<_>>();
|
||||||
|
// https://github.com/rust-lang/rust-analyzer/issues/11404
|
||||||
|
for d in &mut diagnostics {
|
||||||
|
if d.message.is_empty() {
|
||||||
|
d.message = " ".to_string();
|
||||||
|
}
|
||||||
|
if let Some(rds) = d.related_information.as_mut() {
|
||||||
|
for rd in rds {
|
||||||
|
if rd.message.is_empty() {
|
||||||
|
rd.message = " ".to_string();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
let version = from_proto::vfs_path(&url)
|
let version = from_proto::vfs_path(&url)
|
||||||
.map(|path| self.mem_docs.get(&path).map(|it| it.version))
|
.map(|path| self.mem_docs.get(&path).map(|it| it.version))
|
||||||
.unwrap_or_default();
|
.unwrap_or_default();
|
||||||
|
|
Loading…
Reference in a new issue