diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2020-03-09 10:19:26 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2020-03-09 10:19:26 +0000 |
commit | a6133206d1614624bbb51650d33fae04d70bc21a (patch) | |
tree | 461dd502837fe3091e0057f31faa1515fca1ca49 /crates/ra_hir_def | |
parent | 0dbd8ff59b854570329c325431126a078505e5f5 (diff) | |
parent | 100cbc57ce2bd903ecab7d8bfb0abf7777076510 (diff) |
Merge #3527
3527: Simplify r=matklad a=matklad
bors r+
🤖
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_hir_def')
-rw-r--r-- | crates/ra_hir_def/src/find_path.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/lang_item.rs | 3 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres.rs | 2 | ||||
-rw-r--r-- | crates/ra_hir_def/src/nameres/collector.rs | 8 |
4 files changed, 7 insertions, 8 deletions
diff --git a/crates/ra_hir_def/src/find_path.rs b/crates/ra_hir_def/src/find_path.rs index 217e19b01..07ca74ec3 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( | |||
176 | // directly (only through reexports in direct dependencies). | 176 | // directly (only through reexports in direct dependencies). |
177 | for krate in Some(from.krate) | 177 | for krate in Some(from.krate) |
178 | .into_iter() | 178 | .into_iter() |
179 | .chain(crate_graph.crate_data(&from.krate).dependencies.iter().map(|dep| dep.crate_id)) | 179 | .chain(crate_graph[from.krate].dependencies.iter().map(|dep| dep.crate_id)) |
180 | { | 180 | { |
181 | result.extend( | 181 | result.extend( |
182 | importable_locations_in_crate(db, item, krate) | 182 | 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 79e8d8038..6de49730e 100644 --- a/crates/ra_hir_def/src/lang_item.rs +++ b/crates/ra_hir_def/src/lang_item.rs | |||
@@ -116,8 +116,7 @@ impl LangItems { | |||
116 | if let Some(target) = start_crate_target { | 116 | if let Some(target) = start_crate_target { |
117 | return Some(*target); | 117 | return Some(*target); |
118 | } | 118 | } |
119 | db.crate_graph() | 119 | db.crate_graph()[start_crate] |
120 | .crate_data(&start_crate) | ||
121 | .dependencies | 120 | .dependencies |
122 | .iter() | 121 | .iter() |
123 | .find_map(|dep| db.lang_item(dep.crate_id, item.clone())) | 122 | .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 6af0f4a8e..066b43ef9 100644 --- a/crates/ra_hir_def/src/nameres.rs +++ b/crates/ra_hir_def/src/nameres.rs | |||
@@ -179,7 +179,7 @@ impl CrateDefMap { | |||
179 | pub(crate) fn crate_def_map_query(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { | 179 | pub(crate) fn crate_def_map_query(db: &impl DefDatabase, krate: CrateId) -> Arc<CrateDefMap> { |
180 | let _p = profile("crate_def_map_query"); | 180 | let _p = profile("crate_def_map_query"); |
181 | let def_map = { | 181 | let def_map = { |
182 | let edition = db.crate_graph().crate_data(&krate).edition; | 182 | let edition = db.crate_graph()[krate].edition; |
183 | let mut modules: Arena<LocalModuleId, ModuleData> = Arena::default(); | 183 | let mut modules: Arena<LocalModuleId, ModuleData> = Arena::default(); |
184 | let root = modules.alloc(ModuleData::default()); | 184 | let root = modules.alloc(ModuleData::default()); |
185 | CrateDefMap { | 185 | CrateDefMap { |
diff --git a/crates/ra_hir_def/src/nameres/collector.rs b/crates/ra_hir_def/src/nameres/collector.rs index e69f89b80..d0459d9b0 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 | |||
34 | let crate_graph = db.crate_graph(); | 34 | let crate_graph = db.crate_graph(); |
35 | 35 | ||
36 | // populate external prelude | 36 | // populate external prelude |
37 | for dep in &crate_graph.crate_data(&def_map.krate).dependencies { | 37 | for dep in &crate_graph[def_map.krate].dependencies { |
38 | let dep_def_map = db.crate_def_map(dep.crate_id); | 38 | let dep_def_map = db.crate_def_map(dep.crate_id); |
39 | log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); | 39 | log::debug!("crate dep {:?} -> {:?}", dep.name, dep.crate_id); |
40 | def_map.extern_prelude.insert( | 40 | def_map.extern_prelude.insert( |
@@ -51,7 +51,7 @@ pub(super) fn collect_defs(db: &impl DefDatabase, mut def_map: CrateDefMap) -> C | |||
51 | } | 51 | } |
52 | } | 52 | } |
53 | 53 | ||
54 | let cfg_options = crate_graph.cfg_options(def_map.krate); | 54 | let cfg_options = &crate_graph[def_map.krate].cfg_options; |
55 | 55 | ||
56 | let mut collector = DefCollector { | 56 | let mut collector = DefCollector { |
57 | db, | 57 | db, |
@@ -128,7 +128,7 @@ where | |||
128 | DB: DefDatabase, | 128 | DB: DefDatabase, |
129 | { | 129 | { |
130 | fn collect(&mut self) { | 130 | fn collect(&mut self) { |
131 | let file_id = self.db.crate_graph().crate_data(&self.def_map.krate).root_file_id; | 131 | let file_id = self.db.crate_graph()[self.def_map.krate].root_file_id; |
132 | let raw_items = self.db.raw_items(file_id.into()); | 132 | let raw_items = self.db.raw_items(file_id.into()); |
133 | let module_id = self.def_map.root; | 133 | let module_id = self.def_map.root; |
134 | self.def_map.modules[module_id].origin = ModuleOrigin::CrateRoot { definition: file_id }; | 134 | self.def_map.modules[module_id].origin = ModuleOrigin::CrateRoot { definition: file_id }; |
@@ -954,7 +954,7 @@ mod tests { | |||
954 | let krate = db.test_crate(); | 954 | let krate = db.test_crate(); |
955 | 955 | ||
956 | let def_map = { | 956 | let def_map = { |
957 | let edition = db.crate_graph().crate_data(&krate).edition; | 957 | let edition = db.crate_graph()[krate].edition; |
958 | let mut modules: Arena<LocalModuleId, ModuleData> = Arena::default(); | 958 | let mut modules: Arena<LocalModuleId, ModuleData> = Arena::default(); |
959 | let root = modules.alloc(ModuleData::default()); | 959 | let root = modules.alloc(ModuleData::default()); |
960 | CrateDefMap { | 960 | CrateDefMap { |