diff options
author | Jonas Schievink <[email protected]> | 2020-10-20 16:49:21 +0100 |
---|---|---|
committer | Jonas Schievink <[email protected]> | 2020-10-20 16:53:04 +0100 |
commit | 80d27414016903fa591548cff22939d3c43cdd8d (patch) | |
tree | 7e1af2330d87fcefcfcea4e8babfe4130c1e3786 /crates/hir_def/src/nameres.rs | |
parent | a54e481646edb151075d12ca6903091abe7cfc4e (diff) |
Add a (hint) diagnostic for unconfigured items
Diffstat (limited to 'crates/hir_def/src/nameres.rs')
-rw-r--r-- | crates/hir_def/src/nameres.rs | 15 |
1 files changed, 14 insertions, 1 deletions
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 { | |||
286 | use hir_expand::diagnostics::DiagnosticSink; | 286 | use hir_expand::diagnostics::DiagnosticSink; |
287 | use hir_expand::hygiene::Hygiene; | 287 | use hir_expand::hygiene::Hygiene; |
288 | use hir_expand::InFile; | 288 | use hir_expand::InFile; |
289 | use syntax::{ast, AstPtr}; | 289 | use syntax::{ast, AstPtr, SyntaxNodePtr}; |
290 | 290 | ||
291 | use crate::path::ModPath; | 291 | use crate::path::ModPath; |
292 | use crate::{db::DefDatabase, diagnostics::*, nameres::LocalModuleId, AstId}; | 292 | use crate::{db::DefDatabase, diagnostics::*, nameres::LocalModuleId, AstId}; |
@@ -298,6 +298,8 @@ mod diagnostics { | |||
298 | UnresolvedExternCrate { ast: AstId<ast::ExternCrate> }, | 298 | UnresolvedExternCrate { ast: AstId<ast::ExternCrate> }, |
299 | 299 | ||
300 | UnresolvedImport { ast: AstId<ast::Use>, index: usize }, | 300 | UnresolvedImport { ast: AstId<ast::Use>, index: usize }, |
301 | |||
302 | UnconfiguredCode { ast: InFile<SyntaxNodePtr> }, | ||
301 | } | 303 | } |
302 | 304 | ||
303 | #[derive(Debug, PartialEq, Eq)] | 305 | #[derive(Debug, PartialEq, Eq)] |
@@ -336,6 +338,13 @@ mod diagnostics { | |||
336 | Self { in_module: container, kind: DiagnosticKind::UnresolvedImport { ast, index } } | 338 | Self { in_module: container, kind: DiagnosticKind::UnresolvedImport { ast, index } } |
337 | } | 339 | } |
338 | 340 | ||
341 | pub(super) fn unconfigured_code( | ||
342 | container: LocalModuleId, | ||
343 | ast: InFile<SyntaxNodePtr>, | ||
344 | ) -> Self { | ||
345 | Self { in_module: container, kind: DiagnosticKind::UnconfiguredCode { ast } } | ||
346 | } | ||
347 | |||
339 | pub(super) fn add_to( | 348 | pub(super) fn add_to( |
340 | &self, | 349 | &self, |
341 | db: &dyn DefDatabase, | 350 | db: &dyn DefDatabase, |
@@ -385,6 +394,10 @@ mod diagnostics { | |||
385 | sink.push(UnresolvedImport { file: ast.file_id, node: AstPtr::new(&tree) }); | 394 | sink.push(UnresolvedImport { file: ast.file_id, node: AstPtr::new(&tree) }); |
386 | } | 395 | } |
387 | } | 396 | } |
397 | |||
398 | DiagnosticKind::UnconfiguredCode { ast } => { | ||
399 | sink.push(UnconfiguredCode { file: ast.file_id, node: ast.value.clone() }); | ||
400 | } | ||
388 | } | 401 | } |
389 | } | 402 | } |
390 | } | 403 | } |