diff options
-rw-r--r-- | crates/base_db/src/input.rs | 14 | ||||
-rw-r--r-- | crates/hir/src/lib.rs | 9 | ||||
-rw-r--r-- | crates/ide_db/src/search.rs | 4 |
3 files changed, 10 insertions, 17 deletions
diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index e9e8dfc2e..07628935f 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs | |||
@@ -257,7 +257,8 @@ impl CrateGraph { | |||
257 | self.arena.keys().copied() | 257 | self.arena.keys().copied() |
258 | } | 258 | } |
259 | 259 | ||
260 | /// Returns an iterator over all transitive dependencies of the given crate. | 260 | /// Returns an iterator over all transitive dependencies of the given crate, |
261 | /// including the crate itself. | ||
261 | pub fn transitive_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> + '_ { | 262 | pub fn transitive_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> + '_ { |
262 | let mut worklist = vec![of]; | 263 | let mut worklist = vec![of]; |
263 | let mut deps = FxHashSet::default(); | 264 | let mut deps = FxHashSet::default(); |
@@ -270,17 +271,16 @@ impl CrateGraph { | |||
270 | worklist.extend(self[krate].dependencies.iter().map(|dep| dep.crate_id)); | 271 | worklist.extend(self[krate].dependencies.iter().map(|dep| dep.crate_id)); |
271 | } | 272 | } |
272 | 273 | ||
273 | deps.remove(&of); | ||
274 | deps.into_iter() | 274 | deps.into_iter() |
275 | } | 275 | } |
276 | 276 | ||
277 | /// Returns an iterator over all transitive reverse dependencies of the given crate. | 277 | /// Returns all transitive reverse dependencies of the given crate, |
278 | pub fn transitive_reverse_dependencies( | 278 | /// including the crate itself. |
279 | &self, | 279 | pub fn transitive_rev_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> + '_ { |
280 | of: CrateId, | ||
281 | ) -> impl Iterator<Item = CrateId> + '_ { | ||
282 | let mut worklist = vec![of]; | 280 | let mut worklist = vec![of]; |
283 | let mut rev_deps = FxHashSet::default(); | 281 | let mut rev_deps = FxHashSet::default(); |
282 | rev_deps.insert(of); | ||
283 | |||
284 | let mut inverted_graph = FxHashMap::<_, Vec<_>>::default(); | 284 | let mut inverted_graph = FxHashMap::<_, Vec<_>>::default(); |
285 | self.arena.iter().for_each(|(&krate, data)| { | 285 | self.arena.iter().for_each(|(&krate, data)| { |
286 | data.dependencies | 286 | data.dependencies |
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 30b96d7e2..68f4551c0 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -154,11 +154,7 @@ impl Crate { | |||
154 | } | 154 | } |
155 | 155 | ||
156 | pub fn transitive_reverse_dependencies(self, db: &dyn HirDatabase) -> Vec<Crate> { | 156 | pub fn transitive_reverse_dependencies(self, db: &dyn HirDatabase) -> Vec<Crate> { |
157 | db.crate_graph() | 157 | db.crate_graph().transitive_rev_deps(self.id).into_iter().map(|id| Crate { id }).collect() |
158 | .transitive_reverse_dependencies(self.id) | ||
159 | .into_iter() | ||
160 | .map(|id| Crate { id }) | ||
161 | .collect() | ||
162 | } | 158 | } |
163 | 159 | ||
164 | pub fn root_module(self, db: &dyn HirDatabase) -> Module { | 160 | pub fn root_module(self, db: &dyn HirDatabase) -> Module { |
@@ -1572,8 +1568,7 @@ impl Impl { | |||
1572 | pub fn all_for_trait(db: &dyn HirDatabase, trait_: Trait) -> Vec<Impl> { | 1568 | pub fn all_for_trait(db: &dyn HirDatabase, trait_: Trait) -> Vec<Impl> { |
1573 | let krate = trait_.module(db).krate(); | 1569 | let krate = trait_.module(db).krate(); |
1574 | let mut all = Vec::new(); | 1570 | let mut all = Vec::new(); |
1575 | for Crate { id } in krate.transitive_reverse_dependencies(db).into_iter().chain(Some(krate)) | 1571 | for Crate { id } in krate.transitive_reverse_dependencies(db).into_iter() { |
1576 | { | ||
1577 | let impls = db.trait_impls_in_crate(id); | 1572 | let impls = db.trait_impls_in_crate(id); |
1578 | all.extend(impls.for_trait(trait_.id).map(Self::from)) | 1573 | all.extend(impls.for_trait(trait_.id).map(Self::from)) |
1579 | } | 1574 | } |
diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index 324817cd0..8e93de277 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs | |||
@@ -245,9 +245,7 @@ impl Definition { | |||
245 | } | 245 | } |
246 | 246 | ||
247 | if let Some(Visibility::Public) = vis { | 247 | if let Some(Visibility::Public) = vis { |
248 | let source_root_id = db.file_source_root(file_id); | 248 | let mut res = FxHashMap::default(); |
249 | let source_root = db.source_root(source_root_id); | ||
250 | let mut res = source_root.iter().map(|id| (id, None)).collect::<FxHashMap<_, _>>(); | ||
251 | 249 | ||
252 | let krate = module.krate(); | 250 | let krate = module.krate(); |
253 | for rev_dep in krate.transitive_reverse_dependencies(db) { | 251 | for rev_dep in krate.transitive_reverse_dependencies(db) { |