2 diagnostics::{Diagnostic, DiagnosticsContext},
6 // Diagnostic: unresolved-proc-macro
8 // This diagnostic is shown when a procedural macro can not be found. This usually means that
9 // procedural macro support is simply disabled (and hence is only a weak hint instead of an error),
10 // but can also indicate project setup problems.
12 // If you are seeing a lot of "proc macro not expanded" warnings, you can add this option to the
13 // `rust-analyzer.diagnostics.disabled` list to prevent them from showing. Alternatively you can
14 // enable support for procedural macros (see `rust-analyzer.procMacro.enable`).
15 pub(super) fn unresolved_proc_macro(
16 ctx: &DiagnosticsContext<'_>,
17 d: &hir::UnresolvedProcMacro,
19 // Use more accurate position if available.
22 .unwrap_or_else(|| ctx.sema.diagnostics_display_range(d.node.clone()).range);
23 // FIXME: it would be nice to tell the user whether proc macros are currently disabled
24 let message = match &d.macro_name {
25 Some(name) => format!("proc macro `{}` not expanded", name),
26 None => "proc macro not expanded".to_string(),
29 Diagnostic::new("unresolved-proc-macro", message, display_range).severity(Severity::WeakWarning)