diff options
author | Lukas Wirth <[email protected]> | 2021-03-15 13:31:55 +0000 |
---|---|---|
committer | Lukas Wirth <[email protected]> | 2021-03-15 13:31:55 +0000 |
commit | 79561b9d2e901e2624f94ffa7bc6017f0249f23d (patch) | |
tree | ec3fe1d72af1162fbe5d9c948adac5260dc73f75 /crates | |
parent | 6241567948b644739d2ae904e74f5f10cd5b2bb6 (diff) |
goto_implementation: Look at the entire crate graph for trait impls
Diffstat (limited to 'crates')
-rw-r--r-- | crates/hir/src/lib.rs | 11 |
1 files changed, 3 insertions, 8 deletions
diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index 42a805c57..d13b4d5fd 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs | |||
@@ -1488,7 +1488,7 @@ impl Impl { | |||
1488 | pub fn all_for_type(db: &dyn HirDatabase, Type { krate, ty }: Type) -> Vec<Impl> { | 1488 | pub fn all_for_type(db: &dyn HirDatabase, Type { krate, ty }: Type) -> Vec<Impl> { |
1489 | let def_crates = match ty.value.def_crates(db, krate) { | 1489 | let def_crates = match ty.value.def_crates(db, krate) { |
1490 | Some(def_crates) => def_crates, | 1490 | Some(def_crates) => def_crates, |
1491 | None => return vec![], | 1491 | None => return Vec::new(), |
1492 | }; | 1492 | }; |
1493 | 1493 | ||
1494 | let filter = |impl_def: &Impl| { | 1494 | let filter = |impl_def: &Impl| { |
@@ -1498,16 +1498,11 @@ impl Impl { | |||
1498 | }; | 1498 | }; |
1499 | 1499 | ||
1500 | let mut all = Vec::new(); | 1500 | let mut all = Vec::new(); |
1501 | def_crates.iter().for_each(|&id| { | 1501 | def_crates.into_iter().for_each(|id| { |
1502 | all.extend(db.inherent_impls_in_crate(id).all_impls().map(Self::from).filter(filter)) | 1502 | all.extend(db.inherent_impls_in_crate(id).all_impls().map(Self::from).filter(filter)) |
1503 | }); | 1503 | }); |
1504 | let fp = TyFingerprint::for_impl(&ty.value); | 1504 | let fp = TyFingerprint::for_impl(&ty.value); |
1505 | for id in def_crates | 1505 | for id in db.crate_graph().iter() { |
1506 | .iter() | ||
1507 | .flat_map(|&id| Crate { id }.reverse_dependencies(db)) | ||
1508 | .map(|Crate { id }| id) | ||
1509 | .chain(def_crates.iter().copied()) | ||
1510 | { | ||
1511 | match fp { | 1506 | match fp { |
1512 | Some(fp) => all.extend( | 1507 | Some(fp) => all.extend( |
1513 | db.trait_impls_in_crate(id).for_self_ty(fp).map(Self::from).filter(filter), | 1508 | db.trait_impls_in_crate(id).for_self_ty(fp).map(Self::from).filter(filter), |