Merge #11912
11912: Fix `SearchScope::reverse_dependencies` trying to search more files than necessary r=Veykril a=Veykril bors r+ Co-authored-by: Lukas Wirth <lukastw97@gmail.com>
This commit is contained in:
commit
a852758bd6
@ -102,12 +102,18 @@ impl SearchScope {
|
|||||||
/// Build a search scope spanning all the reverse dependencies of the given crate.
|
/// Build a search scope spanning all the reverse dependencies of the given crate.
|
||||||
fn reverse_dependencies(db: &RootDatabase, of: hir::Crate) -> SearchScope {
|
fn reverse_dependencies(db: &RootDatabase, of: hir::Crate) -> SearchScope {
|
||||||
let mut entries = FxHashMap::default();
|
let mut entries = FxHashMap::default();
|
||||||
for rev_dep in of.transitive_reverse_dependencies(db) {
|
let mut insert_modules = |of: hir::Crate| {
|
||||||
let root_file = rev_dep.root_file(db);
|
entries.extend(of.modules(db).into_iter().filter_map(|module| {
|
||||||
let source_root_id = db.file_source_root(root_file);
|
match module.definition_source(db) {
|
||||||
let source_root = db.source_root(source_root_id);
|
InFile { file_id, value: ModuleSource::SourceFile(..) } => {
|
||||||
entries.extend(source_root.iter().map(|id| (id, None)));
|
Some((file_id.original_file(db), None))
|
||||||
}
|
}
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
insert_modules(of);
|
||||||
|
of.transitive_reverse_dependencies(db).into_iter().for_each(insert_modules);
|
||||||
SearchScope { entries }
|
SearchScope { entries }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user