From 45a8f37b6ae230db6c30c013f17d8aebac98a5e1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 23 Mar 2021 12:49:55 +0300 Subject: 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. --- crates/hir/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 30b96d7e2..aefebde06 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -1572,8 +1572,7 @@ impl Impl { pub fn all_for_trait(db: &dyn HirDatabase, trait_: Trait) -> 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)) } -- cgit v1.2.3 From ba48c0d8bd93a0cb5c141f9296843bf5028d960d Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 23 Mar 2021 12:59:51 +0300 Subject: Align naming of deps and revdeps --- crates/hir/src/lib.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) (limited to 'crates/hir') diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index aefebde06..68f4551c0 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -154,11 +154,7 @@ impl Crate { } pub fn transitive_reverse_dependencies(self, db: &dyn HirDatabase) -> Vec { - db.crate_graph() - .transitive_reverse_dependencies(self.id) - .into_iter() - .map(|id| Crate { id }) - .collect() + db.crate_graph().transitive_rev_deps(self.id).into_iter().map(|id| Crate { id }).collect() } pub fn root_module(self, db: &dyn HirDatabase) -> Module { -- cgit v1.2.3