More accurately place proc-macro diagnostic

This commit is contained in:
Jonas Schievink 2020-11-27 16:29:40 +01:00
parent 0432aa0ed7
commit d171838d63
4 changed files with 49 additions and 9 deletions

View file

@ -143,11 +143,13 @@ pub(crate) fn diagnostics(
);
})
.on::<hir::diagnostics::UnresolvedProcMacro, _>(|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))