Skip to content

Commit 4f03dd9

Browse files
authored
Merge pull request rust-lang#18717 from Veykril/push-pomxnvxotwlr
internal: Set `result_id` for pull diagnostics
2 parents 4aa34ab + 1930075 commit 4f03dd9

File tree

1 file changed

+11
-7
lines changed
  • src/tools/rust-analyzer/crates/rust-analyzer/src/handlers

1 file changed

+11
-7
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs

+11-7
Original file line numberDiff line numberDiff line change
@@ -481,27 +481,28 @@ pub(crate) fn handle_document_diagnostics(
481481
snap: GlobalStateSnapshot,
482482
params: lsp_types::DocumentDiagnosticParams,
483483
) -> anyhow::Result<lsp_types::DocumentDiagnosticReportResult> {
484-
const EMPTY: lsp_types::DocumentDiagnosticReportResult =
484+
let empty = || {
485485
lsp_types::DocumentDiagnosticReportResult::Report(
486486
lsp_types::DocumentDiagnosticReport::Full(
487487
lsp_types::RelatedFullDocumentDiagnosticReport {
488488
related_documents: None,
489489
full_document_diagnostic_report: lsp_types::FullDocumentDiagnosticReport {
490-
result_id: None,
490+
result_id: Some("rust-analyzer".to_owned()),
491491
items: vec![],
492492
},
493493
},
494494
),
495-
);
495+
)
496+
};
496497

497498
let file_id = from_proto::file_id(&snap, &params.text_document.uri)?;
498499
let source_root = snap.analysis.source_root_id(file_id)?;
499500
if !snap.analysis.is_local_source_root(source_root)? {
500-
return Ok(EMPTY);
501+
return Ok(empty());
501502
}
502503
let config = snap.config.diagnostics(Some(source_root));
503504
if !config.enabled {
504-
return Ok(EMPTY);
505+
return Ok(empty());
505506
}
506507
let line_index = snap.file_line_index(file_id)?;
507508
let supports_related = snap.config.text_document_diagnostic_related_document_support();
@@ -529,7 +530,7 @@ pub(crate) fn handle_document_diagnostics(
529530
Ok(lsp_types::DocumentDiagnosticReportResult::Report(
530531
lsp_types::DocumentDiagnosticReport::Full(lsp_types::RelatedFullDocumentDiagnosticReport {
531532
full_document_diagnostic_report: lsp_types::FullDocumentDiagnosticReport {
532-
result_id: None,
533+
result_id: Some("rust-analyzer".to_owned()),
533534
items: diagnostics.collect(),
534535
},
535536
related_documents: related_documents.is_empty().not().then(|| {
@@ -539,7 +540,10 @@ pub(crate) fn handle_document_diagnostics(
539540
(
540541
to_proto::url(&snap, id),
541542
lsp_types::DocumentDiagnosticReportKind::Full(
542-
lsp_types::FullDocumentDiagnosticReport { result_id: None, items },
543+
lsp_types::FullDocumentDiagnosticReport {
544+
result_id: Some("rust-analyzer".to_owned()),
545+
items,
546+
},
543547
),
544548
)
545549
})

0 commit comments

Comments
 (0)