From e1aa96f2c5b6cdbf0fb7f49b47209055b7a937f2 Mon Sep 17 00:00:00 2001
From: Kirill Bulatov <mail4score@gmail.com>
Date: Mon, 9 Mar 2020 11:26:46 +0200
Subject: Less abstract CrateData api

---
 crates/ra_hir_def/src/find_path.rs         | 2 +-
 crates/ra_hir_def/src/lang_item.rs         | 4 +++-
 crates/ra_hir_def/src/nameres.rs           | 3 +--
 crates/ra_hir_def/src/nameres/collector.rs | 7 +++----
 4 files changed, 8 insertions(+), 8 deletions(-)

(limited to 'crates/ra_hir_def/src')

diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs
index 43b9b124a..217e19b01 100644
--- a/crates/ra_hir_def/src/find_path.rs
+++ b/crates/ra_hir_def/src/find_path.rs
@@ -176,7 +176,7 @@ fn find_importable_locations(
     // directly (only through reexports in direct dependencies).
     for krate in Some(from.krate)
         .into_iter()
-        .chain(crate_graph.dependencies(from.krate).map(|dep| dep.crate_id))
+        .chain(crate_graph.crate_data(&from.krate).dependencies.iter().map(|dep| dep.crate_id))
     {
         result.extend(
             importable_locations_in_crate(db, item, krate)
diff --git a/crates/ra_hir_def/src/lang_item.rs b/crates/ra_hir_def/src/lang_item.rs
index 5a336ea1f..79e8d8038 100644
--- a/crates/ra_hir_def/src/lang_item.rs
+++ b/crates/ra_hir_def/src/lang_item.rs
@@ -117,7 +117,9 @@ impl LangItems {
             return Some(*target);
         }
         db.crate_graph()
-            .dependencies(start_crate)
+            .crate_data(&start_crate)
+            .dependencies
+            .iter()
             .find_map(|dep| db.lang_item(dep.crate_id, item.clone()))
     }
 
diff --git a/crates/ra_hir_def/src/nameres.rs b/crates/ra_hir_def/src/nameres.rs
index 628c44c99..6af0f4a8e 100644
--- a/crates/ra_hir_def/src/nameres.rs
+++ b/crates/ra_hir_def/src/nameres.rs
@@ -179,8 +179,7 @@ impl CrateDefMap {
     pub(crate) fn crate_def_map_query(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> {
         let _p = profile("crate_def_map_query");
         let def_map = {
-            let crate_graph = db.crate_graph();
-            let edition = crate_graph.edition(krate);
+            let edition = db.crate_graph().crate_data(&krate).edition;
             let mut modules: Arena<LocalModuleId, ModuleData> = Arena::default();
             let root = modules.alloc(ModuleData::default());
             CrateDefMap {
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs
index 51c65a5d7..e69f89b80 100644
--- a/crates/ra_hir_def/src/nameres/collector.rs
+++ b/crates/ra_hir_def/src/nameres/collector.rs
@@ -34,7 +34,7 @@ pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> C
     let crate_graph = db.crate_graph();
 
     // populate external prelude
-    for dep in crate_graph.dependencies(def_map.krate) {
+    for dep in &crate_graph.crate_data(&def_map.krate).dependencies {
         let dep_def_map = db.crate_def_map(dep.crate_id);
         log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id);
         def_map.extern_prelude.insert(
@@ -128,8 +128,7 @@ where
     DB: DefDatabase,
 {
     fn collect(&mut self) {
-        let crate_graph = self.db.crate_graph();
-        let file_id = crate_graph.crate_root(self.def_map.krate);
+        let file_id = self.db.crate_graph().crate_data(&self.def_map.krate).root_file_id;
         let raw_items = self.db.raw_items(file_id.into());
         let module_id = self.def_map.root;
         self.def_map.modules[module_id].origin = ModuleOrigin::CrateRoot { definition: file_id };
@@ -955,7 +954,7 @@ mod tests {
         let krate = db.test_crate();
 
         let def_map = {
-            let edition = db.crate_graph().edition(krate);
+            let edition = db.crate_graph().crate_data(&krate).edition;
             let mut modules: Arena<LocalModuleId, ModuleData> = Arena::default();
             let root = modules.alloc(ModuleData::default());
             CrateDefMap {
-- 
cgit v1.2.3