diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-03-23 10:20:47 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-03-23 10:20:47 +0000 |
commit | 1efd220f2f844596dd22bfd73a8a0c596354be38 (patch) | |
tree | eeba1d8e0e89d6d40ad4802f32dc72af0dfa3e15 /crates/hir | |
parent | bf3a8eb40a1c684ffc9cb40477558ec276253c3b (diff) | |
parent | fa9c6eb4560c3c72a726dba4210af2edbb3dd4bb (diff) |
Merge #8162
8162: Compute more mathematically well-rounded notion of transitive deps r=Veykril a=matklad
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.
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/hir')
-rw-r--r-- | crates/hir/src/lib.rs | 9 |
1 files changed, 2 insertions, 7 deletions
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 | } |