mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 21:35:20 +00:00
Compute more mathematically well-rounded notion of transitive deps
By including the crate itself, we make the resulting set closed with respect to `transitve_reveres_dependencies` operation, as it becomes a proper transitive closure. This just feels more proper and mathy. And, indeed, this actually allows us to simplify call sites somewhat.
This commit is contained in:
parent
4b997b8663
commit
45a8f37b6a
3 changed files with 5 additions and 6 deletions
|
@ -274,13 +274,15 @@ impl CrateGraph {
|
|||
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<Item = CrateId> + '_ {
|
||||
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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue