diff options
Diffstat (limited to 'crates/hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index c8cd04264..bff8edb62 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -913,6 +913,7 @@ impl ModCollector<'_, '_> { | |||
913 | for &item in items { | 913 | for &item in items { |
914 | let attrs = self.item_tree.attrs(item.into()); | 914 | let attrs = self.item_tree.attrs(item.into()); |
915 | if !self.is_cfg_enabled(attrs) { | 915 | if !self.is_cfg_enabled(attrs) { |
916 | self.emit_unconfigured_diagnostic(item); | ||
916 | continue; | 917 | continue; |
917 | } | 918 | } |
918 | let module = | 919 | let module = |
@@ -1323,6 +1324,18 @@ impl ModCollector<'_, '_> { | |||
1323 | fn is_cfg_enabled(&self, attrs: &Attrs) -> bool { | 1324 | fn is_cfg_enabled(&self, attrs: &Attrs) -> bool { |
1324 | attrs.is_cfg_enabled(self.def_collector.cfg_options) | 1325 | attrs.is_cfg_enabled(self.def_collector.cfg_options) |
1325 | } | 1326 | } |
1327 | |||
1328 | fn emit_unconfigured_diagnostic(&mut self, item: ModItem) { | ||
1329 | let ast_id = item.ast_id(self.item_tree); | ||
1330 | let id_map = self.def_collector.db.ast_id_map(self.file_id); | ||
1331 | let syntax_ptr = id_map.get(ast_id).syntax_node_ptr(); | ||
1332 | |||
1333 | let ast_node = InFile::new(self.file_id, syntax_ptr); | ||
1334 | self.def_collector | ||
1335 | .def_map | ||
1336 | .diagnostics | ||
1337 | .push(DefDiagnostic::unconfigured_code(self.module_id, ast_node)); | ||
1338 | } | ||
1326 | } | 1339 | } |
1327 | 1340 | ||
1328 | fn is_macro_rules(path: &ModPath) -> bool { | 1341 | fn is_macro_rules(path: &ModPath) -> bool { |