aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/diagnostics.rs
diff options
context:
space:
mode:
authorJonas Schievink <[email protected]>2020-10-23 18:27:04 +0100
committerJonas Schievink <[email protected]>2020-10-23 18:27:04 +0100
commit93dc6f511bedb7c18319bbf3efe47a7db4b2aa53 (patch)
treec12c45372521a19b24c749e41f7472906afff037 /crates/hir_def/src/diagnostics.rs
parentdd8a75b2cf46a967b3449652fe17c19a8fcc4e41 (diff)
Diagnose #[cfg]s in bodies
Diffstat (limited to 'crates/hir_def/src/diagnostics.rs')
-rw-r--r--crates/hir_def/src/diagnostics.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/hir_def/src/diagnostics.rs b/crates/hir_def/src/diagnostics.rs
index 532496b62..90d9cdcba 100644
--- a/crates/hir_def/src/diagnostics.rs
+++ b/crates/hir_def/src/diagnostics.rs
@@ -4,10 +4,17 @@ use std::any::Any;
4use stdx::format_to; 4use stdx::format_to;
5 5
6use cfg::{CfgExpr, CfgOptions, DnfExpr}; 6use cfg::{CfgExpr, CfgOptions, DnfExpr};
7use hir_expand::diagnostics::{Diagnostic, DiagnosticCode}; 7use hir_expand::diagnostics::{Diagnostic, DiagnosticCode, DiagnosticSink};
8use hir_expand::{HirFileId, InFile}; 8use hir_expand::{HirFileId, InFile};
9use syntax::{ast, AstPtr, SyntaxNodePtr}; 9use syntax::{ast, AstPtr, SyntaxNodePtr};
10 10
11use crate::{db::DefDatabase, DefWithBodyId};
12
13pub fn validate_body(db: &dyn DefDatabase, owner: DefWithBodyId, sink: &mut DiagnosticSink<'_>) {
14 let source_map = db.body_with_source_map(owner).1;
15 source_map.add_diagnostics(db, sink);
16}
17
11// Diagnostic: unresolved-module 18// Diagnostic: unresolved-module
12// 19//
13// This diagnostic is triggered if rust-analyzer is unable to discover referred module. 20// This diagnostic is triggered if rust-analyzer is unable to discover referred module.
@@ -91,7 +98,7 @@ impl Diagnostic for UnresolvedImport {
91// Diagnostic: unconfigured-code 98// Diagnostic: unconfigured-code
92// 99//
93// This diagnostic is shown for code with inactive `#[cfg]` attributes. 100// This diagnostic is shown for code with inactive `#[cfg]` attributes.
94#[derive(Debug)] 101#[derive(Debug, Clone, Eq, PartialEq)]
95pub struct InactiveCode { 102pub struct InactiveCode {
96 pub file: HirFileId, 103 pub file: HirFileId,
97 pub node: SyntaxNodePtr, 104 pub node: SyntaxNodePtr,