diff options
Diffstat (limited to 'crates/hir_def/src/nameres.rs')
-rw-r--r-- | crates/hir_def/src/nameres.rs | 29 |
1 files changed, 23 insertions, 6 deletions
diff --git a/crates/hir_def/src/nameres.rs b/crates/hir_def/src/nameres.rs index 464ffef21..eb41d324e 100644 --- a/crates/hir_def/src/nameres.rs +++ b/crates/hir_def/src/nameres.rs | |||
@@ -172,11 +172,7 @@ pub struct ModuleData { | |||
172 | impl CrateDefMap { | 172 | impl 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; |
@@ -287,10 +283,11 @@ pub enum ModuleSource { | |||
287 | } | 283 | } |
288 | 284 | ||
289 | mod diagnostics { | 285 | mod diagnostics { |
286 | use cfg::{CfgExpr, CfgOptions}; | ||
290 | use hir_expand::diagnostics::DiagnosticSink; | 287 | use hir_expand::diagnostics::DiagnosticSink; |
291 | use hir_expand::hygiene::Hygiene; | 288 | use hir_expand::hygiene::Hygiene; |
292 | use hir_expand::InFile; | 289 | use hir_expand::InFile; |
293 | use syntax::{ast, AstPtr}; | 290 | use syntax::{ast, AstPtr, SyntaxNodePtr}; |
294 | 291 | ||
295 | use crate::path::ModPath; | 292 | use crate::path::ModPath; |
296 | use crate::{db::DefDatabase, diagnostics::*, nameres::LocalModuleId, AstId}; | 293 | use crate::{db::DefDatabase, diagnostics::*, nameres::LocalModuleId, AstId}; |
@@ -302,6 +299,8 @@ mod diagnostics { | |||
302 | UnresolvedExternCrate { ast: AstId<ast::ExternCrate> }, | 299 | UnresolvedExternCrate { ast: AstId<ast::ExternCrate> }, |
303 | 300 | ||
304 | UnresolvedImport { ast: AstId<ast::Use>, index: usize }, | 301 | UnresolvedImport { ast: AstId<ast::Use>, index: usize }, |
302 | |||
303 | UnconfiguredCode { ast: InFile<SyntaxNodePtr>, cfg: CfgExpr, opts: CfgOptions }, | ||
305 | } | 304 | } |
306 | 305 | ||
307 | #[derive(Debug, PartialEq, Eq)] | 306 | #[derive(Debug, PartialEq, Eq)] |
@@ -340,6 +339,15 @@ mod diagnostics { | |||
340 | Self { in_module: container, kind: DiagnosticKind::UnresolvedImport { ast, index } } | 339 | Self { in_module: container, kind: DiagnosticKind::UnresolvedImport { ast, index } } |
341 | } | 340 | } |
342 | 341 | ||
342 | pub(super) fn unconfigured_code( | ||
343 | container: LocalModuleId, | ||
344 | ast: InFile<SyntaxNodePtr>, | ||
345 | cfg: CfgExpr, | ||
346 | opts: CfgOptions, | ||
347 | ) -> Self { | ||
348 | Self { in_module: container, kind: DiagnosticKind::UnconfiguredCode { ast, cfg, opts } } | ||
349 | } | ||
350 | |||
343 | pub(super) fn add_to( | 351 | pub(super) fn add_to( |
344 | &self, | 352 | &self, |
345 | db: &dyn DefDatabase, | 353 | db: &dyn DefDatabase, |
@@ -389,6 +397,15 @@ mod diagnostics { | |||
389 | sink.push(UnresolvedImport { file: ast.file_id, node: AstPtr::new(&tree) }); | 397 | sink.push(UnresolvedImport { file: ast.file_id, node: AstPtr::new(&tree) }); |
390 | } | 398 | } |
391 | } | 399 | } |
400 | |||
401 | DiagnosticKind::UnconfiguredCode { ast, cfg, opts } => { | ||
402 | sink.push(InactiveCode { | ||
403 | file: ast.file_id, | ||
404 | node: ast.value.clone(), | ||
405 | cfg: cfg.clone(), | ||
406 | opts: opts.clone(), | ||
407 | }); | ||
408 | } | ||
392 | } | 409 | } |
393 | } | 410 | } |
394 | } | 411 | } |