diff options
Diffstat (limited to 'crates/hir/src/diagnostics.rs')
-rw-r--r-- | crates/hir/src/diagnostics.rs | 35 |
1 files changed, 9 insertions, 26 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index 70a4d000d..718c86b3a 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs | |||
@@ -17,7 +17,7 @@ pub use crate::diagnostics_sink::{ | |||
17 | }; | 17 | }; |
18 | 18 | ||
19 | macro_rules! diagnostics { | 19 | macro_rules! diagnostics { |
20 | ($($diag:ident),*) => { | 20 | ($($diag:ident,)*) => { |
21 | pub enum AnyDiagnostic {$( | 21 | pub enum AnyDiagnostic {$( |
22 | $diag(Box<$diag>), | 22 | $diag(Box<$diag>), |
23 | )*} | 23 | )*} |
@@ -32,7 +32,13 @@ macro_rules! diagnostics { | |||
32 | }; | 32 | }; |
33 | } | 33 | } |
34 | 34 | ||
35 | diagnostics![UnresolvedModule, UnresolvedExternCrate, UnresolvedImport, MissingFields]; | 35 | diagnostics![ |
36 | UnresolvedModule, | ||
37 | UnresolvedExternCrate, | ||
38 | UnresolvedImport, | ||
39 | UnresolvedMacroCall, | ||
40 | MissingFields, | ||
41 | ]; | ||
36 | 42 | ||
37 | #[derive(Debug)] | 43 | #[derive(Debug)] |
38 | pub struct UnresolvedModule { | 44 | pub struct UnresolvedModule { |
@@ -50,35 +56,12 @@ pub struct UnresolvedImport { | |||
50 | pub decl: InFile<AstPtr<ast::UseTree>>, | 56 | pub decl: InFile<AstPtr<ast::UseTree>>, |
51 | } | 57 | } |
52 | 58 | ||
53 | // Diagnostic: unresolved-macro-call | ||
54 | // | ||
55 | // This diagnostic is triggered if rust-analyzer is unable to resolve the path to a | ||
56 | // macro in a macro invocation. | ||
57 | #[derive(Debug, Clone, Eq, PartialEq)] | 59 | #[derive(Debug, Clone, Eq, PartialEq)] |
58 | pub struct UnresolvedMacroCall { | 60 | pub struct UnresolvedMacroCall { |
59 | pub file: HirFileId, | 61 | pub macro_call: InFile<AstPtr<ast::MacroCall>>, |
60 | pub node: AstPtr<ast::MacroCall>, | ||
61 | pub path: ModPath, | 62 | pub path: ModPath, |
62 | } | 63 | } |
63 | 64 | ||
64 | impl Diagnostic for UnresolvedMacroCall { | ||
65 | fn code(&self) -> DiagnosticCode { | ||
66 | DiagnosticCode("unresolved-macro-call") | ||
67 | } | ||
68 | fn message(&self) -> String { | ||
69 | format!("unresolved macro `{}!`", self.path) | ||
70 | } | ||
71 | fn display_source(&self) -> InFile<SyntaxNodePtr> { | ||
72 | InFile::new(self.file, self.node.clone().into()) | ||
73 | } | ||
74 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | ||
75 | self | ||
76 | } | ||
77 | fn is_experimental(&self) -> bool { | ||
78 | true | ||
79 | } | ||
80 | } | ||
81 | |||
82 | // Diagnostic: inactive-code | 65 | // Diagnostic: inactive-code |
83 | // | 66 | // |
84 | // This diagnostic is shown for code with inactive `#[cfg]` attributes. | 67 | // This diagnostic is shown for code with inactive `#[cfg]` attributes. |