diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-04-02 18:00:57 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-02 18:00:57 +0100 |
commit | 0129628a0f497834a544fa981078b43321c9020a (patch) | |
tree | 0388586d9388710da07d45ba4e1d190c4194da9a /crates/hir_def/src | |
parent | f4d56989b657b15aec6675cf1ba697e3f87eb088 (diff) | |
parent | 7ceaba21dff56ea46f2327895f34a00dc558464d (diff) |
Merge #8297
8297: Only populate prelude for crate-level DefMaps r=jonas-schievink a=jonas-schievink
Fixes https://github.com/rust-analyzer/rust-analyzer/issues/8281
bors r+
Co-authored-by: Jonas Schievink <[email protected]>
Diffstat (limited to 'crates/hir_def/src')
-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 | ||