Skip to content

Commit e691ae0

Browse files
bors[bot]Veykril
andauthored
Merge #11946
11946: internal: Revert #11912 as it parses all visited files r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
2 parents 9093941 + 295f0c5 commit e691ae0

File tree

3 files changed

+13
-16
lines changed

3 files changed

+13
-16
lines changed

crates/base_db/src/input.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl CrateGraph {
334334

335335
/// Returns an iterator over all transitive dependencies of the given crate,
336336
/// including the crate itself.
337-
pub fn transitive_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> + '_ {
337+
pub fn transitive_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> {
338338
let mut worklist = vec![of];
339339
let mut deps = FxHashSet::default();
340340

@@ -351,7 +351,7 @@ impl CrateGraph {
351351

352352
/// Returns all transitive reverse dependencies of the given crate,
353353
/// including the crate itself.
354-
pub fn transitive_rev_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> + '_ {
354+
pub fn transitive_rev_deps(&self, of: CrateId) -> impl Iterator<Item = CrateId> {
355355
let mut worklist = vec![of];
356356
let mut rev_deps = FxHashSet::default();
357357
rev_deps.insert(of);

crates/hir/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,11 @@ impl Crate {
175175
.collect()
176176
}
177177

178-
pub fn transitive_reverse_dependencies(self, db: &dyn HirDatabase) -> Vec<Crate> {
179-
db.crate_graph().transitive_rev_deps(self.id).into_iter().map(|id| Crate { id }).collect()
178+
pub fn transitive_reverse_dependencies(
179+
self,
180+
db: &dyn HirDatabase,
181+
) -> impl Iterator<Item = Crate> {
182+
db.crate_graph().transitive_rev_deps(self.id).map(|id| Crate { id })
180183
}
181184

182185
pub fn root_module(self, db: &dyn HirDatabase) -> Module {

crates/ide_db/src/search.rs

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -102,18 +102,12 @@ impl SearchScope {
102102
/// Build a search scope spanning all the reverse dependencies of the given crate.
103103
fn reverse_dependencies(db: &RootDatabase, of: hir::Crate) -> SearchScope {
104104
let mut entries = FxHashMap::default();
105-
let mut insert_modules = |of: hir::Crate| {
106-
entries.extend(of.modules(db).into_iter().filter_map(|module| {
107-
match module.definition_source(db) {
108-
InFile { file_id, value: ModuleSource::SourceFile(..) } => {
109-
Some((file_id.original_file(db), None))
110-
}
111-
_ => None,
112-
}
113-
}));
114-
};
115-
insert_modules(of);
116-
of.transitive_reverse_dependencies(db).into_iter().for_each(insert_modules);
105+
for rev_dep in of.transitive_reverse_dependencies(db) {
106+
let root_file = rev_dep.root_file(db);
107+
let source_root_id = db.file_source_root(root_file);
108+
let source_root = db.source_root(source_root_id);
109+
entries.extend(source_root.iter().map(|id| (id, None)));
110+
}
117111
SearchScope { entries }
118112
}
119113

0 commit comments

Comments
 (0)