diff options
Diffstat (limited to 'crates/hir/src/diagnostics.rs')
-rw-r--r-- | crates/hir/src/diagnostics.rs | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/crates/hir/src/diagnostics.rs b/crates/hir/src/diagnostics.rs index 8a7c3a4fd..5e2f94698 100644 --- a/crates/hir/src/diagnostics.rs +++ b/crates/hir/src/diagnostics.rs | |||
@@ -15,31 +15,30 @@ pub use crate::diagnostics_sink::{ | |||
15 | Diagnostic, DiagnosticCode, DiagnosticSink, DiagnosticSinkBuilder, | 15 | Diagnostic, DiagnosticCode, DiagnosticSink, DiagnosticSinkBuilder, |
16 | }; | 16 | }; |
17 | 17 | ||
18 | // Diagnostic: unresolved-module | 18 | macro_rules! diagnostics { |
19 | // | 19 | ($($diag:ident)*) => { |
20 | // This diagnostic is triggered if rust-analyzer is unable to discover referred module. | 20 | pub enum AnyDiagnostic {$( |
21 | $diag(Box<$diag>), | ||
22 | )*} | ||
23 | |||
24 | $( | ||
25 | impl From<$diag> for AnyDiagnostic { | ||
26 | fn from(d: $diag) -> AnyDiagnostic { | ||
27 | AnyDiagnostic::$diag(Box::new(d)) | ||
28 | } | ||
29 | } | ||
30 | )* | ||
31 | }; | ||
32 | } | ||
33 | |||
34 | diagnostics![UnresolvedModule]; | ||
35 | |||
21 | #[derive(Debug)] | 36 | #[derive(Debug)] |
22 | pub struct UnresolvedModule { | 37 | pub struct UnresolvedModule { |
23 | pub file: HirFileId, | 38 | pub decl: InFile<AstPtr<ast::Module>>, |
24 | pub decl: AstPtr<ast::Module>, | ||
25 | pub candidate: String, | 39 | pub candidate: String, |
26 | } | 40 | } |
27 | 41 | ||
28 | impl Diagnostic for UnresolvedModule { | ||
29 | fn code(&self) -> DiagnosticCode { | ||
30 | DiagnosticCode("unresolved-module") | ||
31 | } | ||
32 | fn message(&self) -> String { | ||
33 | "unresolved module".to_string() | ||
34 | } | ||
35 | fn display_source(&self) -> InFile<SyntaxNodePtr> { | ||
36 | InFile::new(self.file, self.decl.clone().into()) | ||
37 | } | ||
38 | fn as_any(&self) -> &(dyn Any + Send + 'static) { | ||
39 | self | ||
40 | } | ||
41 | } | ||
42 | |||
43 | // Diagnostic: unresolved-extern-crate | 42 | // Diagnostic: unresolved-extern-crate |
44 | // | 43 | // |
45 | // This diagnostic is triggered if rust-analyzer is unable to discover referred extern crate. | 44 | // This diagnostic is triggered if rust-analyzer is unable to discover referred extern crate. |