File tree Expand file tree Collapse file tree 1 file changed +10
-2
lines changed
crates/rust-analyzer/src/diagnostics Expand file tree Collapse file tree 1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -254,14 +254,22 @@ pub(crate) fn map_rust_diagnostic_to_lsp(
254
254
let span_stack = std:: iter:: successors ( Some ( * primary_span) , |span| {
255
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
262
let secondary_location = location ( workspace_root, & span) ;
259
263
if secondary_location == primary_location {
260
264
continue ;
261
265
}
262
266
related_info_macro_calls. push ( lsp_types:: DiagnosticRelatedInformation {
263
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
274
// For the additional in-macro diagnostic we add the inverse message pointing to the error location in code.
267
275
let information_for_additional_diagnostic =
You can’t perform that action at this time.
0 commit comments