aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_def/src/nameres.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_def/src/nameres.rs')
-rw-r--r--crates/hir_def/src/nameres.rs21
1 files changed, 15 insertions, 6 deletions
diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs
index 464ffef21..01a28aeeb 100644
--- a/crates/hir_def/src/nameres.rs
+++ b/crates/hir_def/src/nameres.rs
@@ -172,11 +172,7 @@ pub struct ModuleData {
172impl CrateDefMap { 172impl CrateDefMap {
173 pub(crate) fn crate_def_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { 173 pub(crate) fn crate_def_map_query(db: &dyn DefDatabase, krate: CrateId) -> Arc<CrateDefMap> {
174 let _p = profile::span("crate_def_map_query").detail(|| { 174 let _p = profile::span("crate_def_map_query").detail(|| {
175 db.crate_graph()[krate] 175 db.crate_graph()[krate].display_name.as_deref().unwrap_or_default().to_string()
176 .declaration_name
177 .as_ref()
178 .map(ToString::to_string)
179 .unwrap_or_default()
180 }); 176 });
181 let def_map = { 177 let def_map = {
182 let edition = db.crate_graph()[krate].edition; 178 let edition = db.crate_graph()[krate].edition;
@@ -290,7 +286,7 @@ mod diagnostics {
290 use hir_expand::diagnostics::DiagnosticSink; 286 use hir_expand::diagnostics::DiagnosticSink;
291 use hir_expand::hygiene::Hygiene; 287 use hir_expand::hygiene::Hygiene;
292 use hir_expand::InFile; 288 use hir_expand::InFile;
293 use syntax::{ast, AstPtr}; 289 use syntax::{ast, AstPtr, SyntaxNodePtr};
294 290
295 use crate::path::ModPath; 291 use crate::path::ModPath;
296 use crate::{db::DefDatabase, diagnostics::*, nameres::LocalModuleId, AstId}; 292 use crate::{db::DefDatabase, diagnostics::*, nameres::LocalModuleId, AstId};
@@ -302,6 +298,8 @@ mod diagnostics {
302 UnresolvedExternCrate { ast: AstId<ast::ExternCrate> }, 298 UnresolvedExternCrate { ast: AstId<ast::ExternCrate> },
303 299
304 UnresolvedImport { ast: AstId<ast::Use>, index: usize }, 300 UnresolvedImport { ast: AstId<ast::Use>, index: usize },
301
302 UnconfiguredCode { ast: InFile<SyntaxNodePtr> },
305 } 303 }
306 304
307 #[derive(Debug, PartialEq, Eq)] 305 #[derive(Debug, PartialEq, Eq)]
@@ -340,6 +338,13 @@ mod diagnostics {
340 Self { in_module: container, kind: DiagnosticKind::UnresolvedImport { ast, index } } 338 Self { in_module: container, kind: DiagnosticKind::UnresolvedImport { ast, index } }
341 } 339 }
342 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
343 pub(super) fn add_to( 348 pub(super) fn add_to(
344 &self, 349 &self,
345 db: &dyn DefDatabase, 350 db: &dyn DefDatabase,
@@ -389,6 +394,10 @@ mod diagnostics {
389 sink.push(UnresolvedImport { file: ast.file_id, node: AstPtr::new(&tree) }); 394 sink.push(UnresolvedImport { file: ast.file_id, node: AstPtr::new(&tree) });
390 } 395 }
391 } 396 }
397
398 DiagnosticKind::UnconfiguredCode { ast } => {
399 sink.push(InactiveCode { file: ast.file_id, node: ast.value.clone() });
400 }
392 } 401 }
393 } 402 }
394 } 403 }