aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir_def/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir_def/src')
-rw-r--r--crates/ra_hir_def/src/nameres/collector.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 7e6083961..36a61dc3d 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -27,6 +27,7 @@ pub(super) fn collect_defs(db: &impl DefDatabase2, mut def_map: CrateDefMap) ->
27 let crate_graph = db.crate_graph(); 27 let crate_graph = db.crate_graph();
28 28
29 // populate external prelude 29 // populate external prelude
30 let mut prelude_is_core = false;
30 for dep in crate_graph.dependencies(def_map.krate) { 31 for dep in crate_graph.dependencies(def_map.krate) {
31 let dep_def_map = db.crate_def_map(dep.crate_id); 32 let dep_def_map = db.crate_def_map(dep.crate_id);
32 log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); 33 log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id);
@@ -36,10 +37,13 @@ pub(super) fn collect_defs(db: &impl DefDatabase2, mut def_map: CrateDefMap) ->
36 ); 37 );
37 38
38 // look for the prelude 39 // look for the prelude
39 if def_map.prelude.is_none() { 40 // If the prelude is the "core" prelude, try to replace it with a higher
41 // level prelude (e.g. "std") if available.
42 if def_map.prelude.is_none() || prelude_is_core {
40 let map = db.crate_def_map(dep.crate_id); 43 let map = db.crate_def_map(dep.crate_id);
41 if map.prelude.is_some() { 44 if map.prelude.is_some() {
42 def_map.prelude = map.prelude; 45 def_map.prelude = map.prelude;
46 prelude_is_core = dep.name == "core";
43 } 47 }
44 } 48 }
45 } 49 }