diff options
Diffstat (limited to 'crates/ide/src/diagnostics')
-rw-r--r-- | crates/ide/src/diagnostics/inactive_code.rs | 6 | ||||
-rw-r--r-- | crates/ide/src/diagnostics/unresolved_proc_macro.rs | 30 |
2 files changed, 35 insertions, 1 deletions
diff --git a/crates/ide/src/diagnostics/inactive_code.rs b/crates/ide/src/diagnostics/inactive_code.rs index 52f97cb4c..afe333204 100644 --- a/crates/ide/src/diagnostics/inactive_code.rs +++ b/crates/ide/src/diagnostics/inactive_code.rs | |||
@@ -1,7 +1,10 @@ | |||
1 | use cfg::DnfExpr; | 1 | use cfg::DnfExpr; |
2 | use stdx::format_to; | 2 | use stdx::format_to; |
3 | 3 | ||
4 | use crate::diagnostics::{Diagnostic, DiagnosticsContext}; | 4 | use crate::{ |
5 | diagnostics::{Diagnostic, DiagnosticsContext}, | ||
6 | Severity, | ||
7 | }; | ||
5 | 8 | ||
6 | // Diagnostic: inactive-code | 9 | // Diagnostic: inactive-code |
7 | // | 10 | // |
@@ -27,6 +30,7 @@ pub(super) fn inactive_code( | |||
27 | message, | 30 | message, |
28 | ctx.sema.diagnostics_display_range(d.node.clone()).range, | 31 | ctx.sema.diagnostics_display_range(d.node.clone()).range, |
29 | ) | 32 | ) |
33 | .severity(Severity::WeakWarning) | ||
30 | .with_unused(true); | 34 | .with_unused(true); |
31 | Some(res) | 35 | Some(res) |
32 | } | 36 | } |
diff --git a/crates/ide/src/diagnostics/unresolved_proc_macro.rs b/crates/ide/src/diagnostics/unresolved_proc_macro.rs new file mode 100644 index 000000000..3dc6ab451 --- /dev/null +++ b/crates/ide/src/diagnostics/unresolved_proc_macro.rs | |||
@@ -0,0 +1,30 @@ | |||
1 | use crate::{ | ||
2 | diagnostics::{Diagnostic, DiagnosticsContext}, | ||
3 | Severity, | ||
4 | }; | ||
5 | |||
6 | // Diagnostic: unresolved-proc-macro | ||
7 | // | ||
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. | ||
11 | // | ||
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, | ||
18 | ) -> Diagnostic { | ||
19 | // Use more accurate position if available. | ||
20 | let display_range = d | ||
21 | .precise_location | ||
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(), | ||
27 | }; | ||
28 | |||
29 | Diagnostic::new("unresolved-proc-macro", message, display_range).severity(Severity::WeakWarning) | ||
30 | } | ||