diff options
author | Jonas Schievink <[email protected]> | 2021-04-01 13:44:20 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2021-04-01 13:44:20 +0100 |
commit | 066330e95349f96a2481ec727bfe50f9dbca9951 (patch) | |
tree | 509ba5d20745cbf43a011f2f268b4233383094f4 /crates | |
parent | 7c87e49638f6c4319cb9da3a59f87ca8e441c00d (diff) |
Adjust message when pointing at location in macro
Diffstat (limited to 'crates')
-rw-r--r-- | crates/rust-analyzer/src/diagnostics/to_proto.rs | 12 |
1 files changed, 10 insertions, 2 deletions
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( | |||
254 | let span_stack = std::iter::successors(Some(*primary_span), |span| { | 254 | let span_stack = std::iter::successors(Some(*primary_span), |span| { |
255 | Some(&span.expansion.as_ref()?.span) | 255 | Some(&span.expansion.as_ref()?.span) |
256 | }); | 256 | }); |
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 | |||
258 | let secondary_location = location(workspace_root, &span); | 262 | let secondary_location = location(workspace_root, &span); |
259 | if secondary_location == primary_location { | 263 | if secondary_location == primary_location { |
260 | continue; | 264 | continue; |
261 | } | 265 | } |
262 | related_info_macro_calls.push(lsp_types::DiagnosticRelatedInformation { | 266 | related_info_macro_calls.push(lsp_types::DiagnosticRelatedInformation { |
263 | location: secondary_location.clone(), | 267 | 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 | }, | ||
265 | }); | 273 | }); |
266 | // For the additional in-macro diagnostic we add the inverse message pointing to the error location in code. | 274 | // For the additional in-macro diagnostic we add the inverse message pointing to the error location in code. |
267 | let information_for_additional_diagnostic = | 275 | let information_for_additional_diagnostic = |