diff options
Diffstat (limited to 'crates/ra_hir/src/ty/traits.rs')
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index a1ed0c028..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. |
2 | use std::sync::{Arc, Mutex}; | 2 | use std::sync::{Arc, Mutex}; |
3 | 3 | ||
4 | use rustc_hash::FxHashSet; | ||
4 | use log::debug; | 5 | use log::debug; |
5 | use chalk_ir::cast::Cast; | 6 | use 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 | ||
48 | fn solve( | 49 | fn solve( |
@@ -125,11 +126,11 @@ fn solution_from_chalk(db: &impl HirDatabase, solution: chalk_solve::Solution) - | |||
125 | } | 126 | } |
126 | 127 | ||
127 | #[derive(Clone, Debug, PartialEq, Eq)] | 128 | #[derive(Clone, Debug, PartialEq, Eq)] |
128 | pub(crate) struct SolutionVariables(pub Canonical<Vec<Ty>>); | 129 | pub struct SolutionVariables(pub Canonical<Vec<Ty>>); |
129 | 130 | ||
130 | #[derive(Clone, Debug, PartialEq, Eq)] | 131 | #[derive(Clone, Debug, PartialEq, Eq)] |
131 | /// A (possible) solution for a proposed goal. | 132 | /// A (possible) solution for a proposed goal. |
132 | pub(crate) enum Solution { | 133 | pub enum Solution { |
133 | /// The goal indeed holds, and there is a unique value for all existential | 134 | /// The goal indeed holds, and there is a unique value for all existential |
134 | /// variables. | 135 | /// variables. |
135 | Unique(SolutionVariables), | 136 | Unique(SolutionVariables), |
@@ -144,7 +145,7 @@ pub(crate) enum Solution { | |||
144 | #[derive(Clone, Debug, PartialEq, Eq)] | 145 | #[derive(Clone, Debug, PartialEq, Eq)] |
145 | /// When a goal holds ambiguously (e.g., because there are multiple possible | 146 | /// When a goal holds ambiguously (e.g., because there are multiple possible |
146 | /// solutions), we issue a set of *guidance* back to type inference. | 147 | /// solutions), we issue a set of *guidance* back to type inference. |
147 | pub(crate) enum Guidance { | 148 | pub enum Guidance { |
148 | /// The existential variables *must* have the given values if the goal is | 149 | /// The existential variables *must* have the given values if the goal is |
149 | /// ever to hold, but that alone isn't enough to guarantee the goal will | 150 | /// ever to hold, but that alone isn't enough to guarantee the goal will |
150 | /// actually hold. | 151 | /// actually hold. |