diff --git a/crates/base_db/src/input.rs b/crates/base_db/src/input.rs index e9e8dfc2e98..248ab1de24b 100644 --- a/crates/base_db/src/input.rs +++ b/crates/base_db/src/input.rs @@ -274,13 +274,15 @@ pub fn transitive_deps(&self, of: CrateId) -> impl Iterator + '_ deps.into_iter() } - /// Returns an iterator over all transitive reverse dependencies of the given crate. + /// Returns all transitive reverse dependencies of the given crate, + /// including the crate itself. pub fn transitive_reverse_dependencies( &self, of: CrateId, ) -> impl Iterator + '_ { let mut worklist = vec![of]; let mut rev_deps = FxHashSet::default(); + rev_deps.insert(of); let mut inverted_graph = FxHashMap::<_, Vec<_>>::default(); self.arena.iter().for_each(|(&krate, data)| { data.dependencies diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 30b96d7e2ed..aefebde06e6 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1572,8 +1572,7 @@ pub fn all_for_type(db: &dyn HirDatabase, Type { krate, ty, .. }: Type) -> Vec Vec { let krate = trait_.module(db).krate(); let mut all = Vec::new(); - for Crate { id } in krate.transitive_reverse_dependencies(db).into_iter().chain(Some(krate)) - { + for Crate { id } in krate.transitive_reverse_dependencies(db).into_iter() { let impls = db.trait_impls_in_crate(id); all.extend(impls.for_trait(trait_.id).map(Self::from)) } diff --git a/crates/ide_db/src/search.rs b/crates/ide_db/src/search.rs index 324817cd0d8..8e93de277e9 100644 --- a/crates/ide_db/src/search.rs +++ b/crates/ide_db/src/search.rs @@ -245,9 +245,7 @@ fn search_scope(&self, db: &RootDatabase) -> SearchScope { } if let Some(Visibility::Public) = vis { - let source_root_id = db.file_source_root(file_id); - let source_root = db.source_root(source_root_id); - let mut res = source_root.iter().map(|id| (id, None)).collect::>(); + let mut res = FxHashMap::default(); let krate = module.krate(); for rev_dep in krate.transitive_reverse_dependencies(db) {