aboutsummaryrefslogtreecommitdiff
path: root/crates/ide_diagnostics/src/handlers/unresolved_proc_macro.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ide_diagnostics/src/handlers/unresolved_proc_macro.rs')
-rw-r--r--crates/ide_diagnostics/src/handlers/unresolved_proc_macro.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/crates/ide_diagnostics/src/handlers/unresolved_proc_macro.rs b/crates/ide_diagnostics/src/handlers/unresolved_proc_macro.rs
new file mode 100644
index 000000000..fde1d1323
--- /dev/null
+++ b/crates/ide_diagnostics/src/handlers/unresolved_proc_macro.rs
@@ -0,0 +1,27 @@
1use crate::{Diagnostic, DiagnosticsContext, Severity};
2
3// Diagnostic: unresolved-proc-macro
4//
5// This diagnostic is shown when a procedural macro can not be found. This usually means that
6// procedural macro support is simply disabled (and hence is only a weak hint instead of an error),
7// but can also indicate project setup problems.
8//
9// If you are seeing a lot of "proc macro not expanded" warnings, you can add this option to the
10// `rust-analyzer.diagnostics.disabled` list to prevent them from showing. Alternatively you can
11// enable support for procedural macros (see `rust-analyzer.procMacro.enable`).
12pub(crate) fn unresolved_proc_macro(
13 ctx: &DiagnosticsContext<'_>,
14 d: &hir::UnresolvedProcMacro,
15) -> Diagnostic {
16 // Use more accurate position if available.
17 let display_range = d
18 .precise_location
19 .unwrap_or_else(|| ctx.sema.diagnostics_display_range(d.node.clone()).range);
20 // FIXME: it would be nice to tell the user whether proc macros are currently disabled
21 let message = match &d.macro_name {
22 Some(name) => format!("proc macro `{}` not expanded", name),
23 None => "proc macro not expanded".to_string(),
24 };
25
26 Diagnostic::new("unresolved-proc-macro", message, display_range).severity(Severity::WeakWarning)
27}