From 80d27414016903fa591548cff22939d3c43cdd8d Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Tue, 20 Oct 2020 17:49:21 +0200 Subject: Add a (hint) diagnostic for unconfigured items --- crates/hir_def/src/nameres.rs | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'crates/hir_def/src/nameres.rs') diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs index 3d04f81c6..8bb3a659f 100644 --- a/crates/hir_def/src/nameres.rs +++ b/crates/hir_def/src/nameres.rs @@ -286,7 +286,7 @@ mod diagnostics { use hir_expand::diagnostics::DiagnosticSink; use hir_expand::hygiene::Hygiene; use hir_expand::InFile; - use syntax::{ast, AstPtr}; + use syntax::{ast, AstPtr, SyntaxNodePtr}; use crate::path::ModPath; use crate::{db::DefDatabase, diagnostics::*, nameres::LocalModuleId, AstId}; @@ -298,6 +298,8 @@ mod diagnostics { UnresolvedExternCrate { ast: AstId }, UnresolvedImport { ast: AstId, index: usize }, + + UnconfiguredCode { ast: InFile }, } #[derive(Debug, PartialEq, Eq)] @@ -336,6 +338,13 @@ mod diagnostics { Self { in_module: container, kind: DiagnosticKind::UnresolvedImport { ast, index } } } + pub(super) fn unconfigured_code( + container: LocalModuleId, + ast: InFile, + ) -> Self { + Self { in_module: container, kind: DiagnosticKind::UnconfiguredCode { ast } } + } + pub(super) fn add_to( &self, db: &dyn DefDatabase, @@ -385,6 +394,10 @@ mod diagnostics { sink.push(UnresolvedImport { file: ast.file_id, node: AstPtr::new(&tree) }); } } + + DiagnosticKind::UnconfiguredCode { ast } => { + sink.push(UnconfiguredCode { file: ast.file_id, node: ast.value.clone() }); + } } } } -- cgit v1.2.3