aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2019-05-07 11:09:57 +0100
committerFlorian Diebold <[email protected]>2019-05-07 12:45:29 +0100
commit530b3047ed19a6468fc75e5a5ec14763093a069d (patch)
treef0d040f649916c46ff32622dc7586634dfb7d092
parent880ef25a9e9fe3071181d27c6d8ea672bf76d680 (diff)
Deduplicate impls in impls_for_trait
This was duplicating impls in dependencies a lot...
-rw-r--r--crates/ra_hir/src/ty/traits.rs5
1 files changed, 3 insertions, 2 deletions
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs
index f70a32575..4bbc99f0e 100644
--- a/crates/ra_hir/src/ty/traits.rs
+++ b/crates/ra_hir/src/ty/traits.rs
@@ -1,6 +1,7 @@
1//! Trait solving using Chalk. 1//! Trait solving using Chalk.
2use std::sync::{Arc, Mutex}; 2use std::sync::{Arc, Mutex};
3 3
4use rustc_hash::FxHashSet;
4use log::debug; 5use log::debug;
5use chalk_ir::cast::Cast; 6use chalk_ir::cast::Cast;
6 7
@@ -31,7 +32,7 @@ pub(crate) fn impls_for_trait(
31 krate: Crate, 32 krate: Crate,
32 trait_: Trait, 33 trait_: Trait,
33) -> Arc<[ImplBlock]> { 34) -> Arc<[ImplBlock]> {
34 let mut impls = Vec::new(); 35 let mut impls = FxHashSet::default();
35 // We call the query recursively here. On the one hand, this means we can 36 // We call the query recursively here. On the one hand, this means we can
36 // reuse results from queries for different crates; on the other hand, this 37 // reuse results from queries for different crates; on the other hand, this
37 // will only ever get called for a few crates near the root of the tree (the 38 // will only ever get called for a few crates near the root of the tree (the
@@ -42,7 +43,7 @@ pub(crate) fn impls_for_trait(
42 } 43 }
43 let crate_impl_blocks = db.impls_in_crate(krate); 44 let crate_impl_blocks = db.impls_in_crate(krate);
44 impls.extend(crate_impl_blocks.lookup_impl_blocks_for_trait(&trait_)); 45 impls.extend(crate_impl_blocks.lookup_impl_blocks_for_trait(&trait_));
45 impls.into() 46 impls.into_iter().collect::<Vec<_>>().into()
46} 47}
47 48
48fn solve( 49fn solve(