diff options
Diffstat (limited to 'crates/hir_def/src/nameres/collector.rs')
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index f30172d90..59b6644c3 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -122,13 +122,13 @@ enum ImportSource { | |||
122 | 122 | ||
123 | #[derive(Clone, Debug, Eq, PartialEq)] | 123 | #[derive(Clone, Debug, Eq, PartialEq)] |
124 | struct Import { | 124 | struct Import { |
125 | pub path: ModPath, | 125 | path: ModPath, |
126 | pub alias: Option<ImportAlias>, | 126 | alias: Option<ImportAlias>, |
127 | pub visibility: RawVisibility, | 127 | visibility: RawVisibility, |
128 | pub is_glob: bool, | 128 | is_glob: bool, |
129 | pub is_prelude: bool, | 129 | is_prelude: bool, |
130 | pub is_extern_crate: bool, | 130 | is_extern_crate: bool, |
131 | pub is_macro_use: bool, | 131 | is_macro_use: bool, |
132 | source: ImportSource, | 132 | source: ImportSource, |
133 | } | 133 | } |
134 | 134 | ||
@@ -218,15 +218,18 @@ impl DefCollector<'_> { | |||
218 | let item_tree = self.db.item_tree(file_id.into()); | 218 | let item_tree = self.db.item_tree(file_id.into()); |
219 | let module_id = self.def_map.root; | 219 | let module_id = self.def_map.root; |
220 | self.def_map.modules[module_id].origin = ModuleOrigin::CrateRoot { definition: file_id }; | 220 | self.def_map.modules[module_id].origin = ModuleOrigin::CrateRoot { definition: file_id }; |
221 | ModCollector { | 221 | let mut root_collector = ModCollector { |
222 | def_collector: &mut *self, | 222 | def_collector: &mut *self, |
223 | macro_depth: 0, | 223 | macro_depth: 0, |
224 | module_id, | 224 | module_id, |
225 | file_id: file_id.into(), | 225 | file_id: file_id.into(), |
226 | item_tree: &item_tree, | 226 | item_tree: &item_tree, |
227 | mod_dir: ModDir::root(), | 227 | mod_dir: ModDir::root(), |
228 | }; | ||
229 | if item_tree.top_level_attrs().cfg().map_or(true, |cfg| root_collector.is_cfg_enabled(&cfg)) | ||
230 | { | ||
231 | root_collector.collect(item_tree.top_level_items()); | ||
228 | } | 232 | } |
229 | .collect(item_tree.top_level_items()); | ||
230 | 233 | ||
231 | // main name resolution fixed-point loop. | 234 | // main name resolution fixed-point loop. |
232 | let mut i = 0; | 235 | let mut i = 0; |