From 0432aa0ed7be3f41d41928499abc688a956214cf Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Thu, 26 Nov 2020 20:09:54 +0100 Subject: Publish diagnostics for macro expansion errors --- crates/ide/src/diagnostics.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'crates/ide/src') diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 3df73ed4f..8b4ceb9a1 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs @@ -142,6 +142,13 @@ pub(crate) fn diagnostics( .with_code(Some(d.code())), ); }) + .on::(|d| { + // FIXME: it would be nice to tell the user whether proc macros are currently disabled + res.borrow_mut().push( + Diagnostic::hint(sema.diagnostics_display_range(d).range, d.message()) + .with_code(Some(d.code())), + ); + }) // Only collect experimental diagnostics when they're enabled. .filter(|diag| !(diag.is_experimental() && config.disable_experimental)) .filter(|diag| !config.disabled.contains(diag.code().as_str())); -- cgit v1.2.3 From d171838d63907d004ab935d6564bfeb4238d5540 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Fri, 27 Nov 2020 16:29:40 +0100 Subject: More accurately place proc-macro diagnostic --- crates/ide/src/diagnostics.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'crates/ide/src') diff --git a/crates/ide/src/diagnostics.rs b/crates/ide/src/diagnostics.rs index 8b4ceb9a1..9d3d88289 100644 --- a/crates/ide/src/diagnostics.rs +++ b/crates/ide/src/diagnostics.rs @@ -143,11 +143,13 @@ pub(crate) fn diagnostics( ); }) .on::(|d| { + // Use more accurate position if available. + let display_range = + d.precise_location.unwrap_or_else(|| sema.diagnostics_display_range(d).range); + // FIXME: it would be nice to tell the user whether proc macros are currently disabled - res.borrow_mut().push( - Diagnostic::hint(sema.diagnostics_display_range(d).range, d.message()) - .with_code(Some(d.code())), - ); + res.borrow_mut() + .push(Diagnostic::hint(display_range, d.message()).with_code(Some(d.code()))); }) // Only collect experimental diagnostics when they're enabled. .filter(|diag| !(diag.is_experimental() && config.disable_experimental)) -- cgit v1.2.3