From 066330e95349f96a2481ec727bfe50f9dbca9951 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 1 Apr 2021 14:44:20 +0200 Subject: Adjust message when pointing at location in macro --- crates/rust-analyzer/src/diagnostics/to_proto.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'crates') diff --git a/crates/rust-analyzer/src/diagnostics/to_proto.rs b/crates/rust-analyzer/src/diagnostics/to_proto.rs index 89fe834f4..8723c450c 100644 --- a/crates/rust-analyzer/src/diagnostics/to_proto.rs +++ b/crates/rust-analyzer/src/diagnostics/to_proto.rs @@ -254,14 +254,22 @@ pub(crate) fn map_rust_diagnostic_to_lsp( let span_stack = std::iter::successors(Some(*primary_span), |span| { Some(&span.expansion.as_ref()?.span) }); - for span in span_stack { + for (i, span) in span_stack.enumerate() { + // First span is the original diagnostic, others are macro call locations that + // generated that code. + let is_in_macro_call = i != 0; + let secondary_location = location(workspace_root, &span); if secondary_location == primary_location { continue; } related_info_macro_calls.push(lsp_types::DiagnosticRelatedInformation { location: secondary_location.clone(), - message: "Error originated from macro call here".to_string(), + message: if is_in_macro_call { + "Error originated from macro call here".to_string() + } else { + "Actual error occurred here".to_string() + }, }); // For the additional in-macro diagnostic we add the inverse message pointing to the error location in code. let information_for_additional_diagnostic = -- cgit v1.2.3