diff options
Diffstat (limited to 'crates/hir_def')
-rw-r--r-- | crates/hir_def/src/nameres/collector.rs | 30 |
1 files changed, 16 insertions, 14 deletions
diff --git a/crates/hir_def/src/nameres/collector.rs b/crates/hir_def/src/nameres/collector.rs index 5badefabf..6f946a6dd 100644 --- a/crates/hir_def/src/nameres/collector.rs +++ b/crates/hir_def/src/nameres/collector.rs | |||
@@ -54,20 +54,22 @@ pub(super) fn collect_defs( | |||
54 | ) -> DefMap { | 54 | ) -> DefMap { |
55 | let crate_graph = db.crate_graph(); | 55 | let crate_graph = db.crate_graph(); |
56 | 56 | ||
57 | // populate external prelude | 57 | if block.is_none() { |
58 | for dep in &crate_graph[def_map.krate].dependencies { | 58 | // populate external prelude |
59 | log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); | 59 | for dep in &crate_graph[def_map.krate].dependencies { |
60 | let dep_def_map = db.crate_def_map(dep.crate_id); | 60 | log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); |
61 | def_map | 61 | let dep_def_map = db.crate_def_map(dep.crate_id); |
62 | .extern_prelude | 62 | def_map |
63 | .insert(dep.as_name(), dep_def_map.module_id(dep_def_map.root).into()); | 63 | .extern_prelude |
64 | 64 | .insert(dep.as_name(), dep_def_map.module_id(dep_def_map.root).into()); | |
65 | // look for the prelude | 65 | |
66 | // If the dependency defines a prelude, we overwrite an already defined | 66 | // look for the prelude |
67 | // prelude. This is necessary to import the "std" prelude if a crate | 67 | // If the dependency defines a prelude, we overwrite an already defined |
68 | // depends on both "core" and "std". | 68 | // prelude. This is necessary to import the "std" prelude if a crate |
69 | if dep_def_map.prelude.is_some() { | 69 | // depends on both "core" and "std". |
70 | def_map.prelude = dep_def_map.prelude; | 70 | if dep_def_map.prelude.is_some() { |
71 | def_map.prelude = dep_def_map.prelude; | ||
72 | } | ||
71 | } | 73 | } |
72 | } | 74 | } |
73 | 75 | ||