Skip to content

Commit 066330e

Browse files
Adjust message when pointing at location in macro
1 parent 7c87e49 commit 066330e

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,14 +254,22 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
254254
let span_stack = std::iter::successors(Some(*primary_span), |span| {
255255
Some(&span.expansion.as_ref()?.span)
256256
});
257-
for span in span_stack {
257+
for (i, span) in span_stack.enumerate() {
258+
// First span is the original diagnostic, others are macro call locations that
259+
// generated that code.
260+
let is_in_macro_call = i != 0;
261+
258262
let secondary_location = location(workspace_root, &span);
259263
if secondary_location == primary_location {
260264
continue;
261265
}
262266
related_info_macro_calls.push(lsp_types::DiagnosticRelatedInformation {
263267
location: secondary_location.clone(),
264-
message: "Error originated from macro call here".to_string(),
268+
message: if is_in_macro_call {
269+
"Error originated from macro call here".to_string()
270+
} else {
271+
"Actual error occurred here".to_string()
272+
},
265273
});
266274
// For the additional in-macro diagnostic we add the inverse message pointing to the error location in code.
267275
let information_for_additional_diagnostic =

0 commit comments

Comments
 (0)