diff options
Diffstat (limited to 'crates/ra_hir/src/ty/traits.rs')
-rw-r--r-- | crates/ra_hir/src/ty/traits.rs | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/crates/ra_hir/src/ty/traits.rs b/crates/ra_hir/src/ty/traits.rs index 01f350bc1..d99843319 100644 --- a/crates/ra_hir/src/ty/traits.rs +++ b/crates/ra_hir/src/ty/traits.rs | |||
@@ -93,7 +93,7 @@ impl<T> InEnvironment<T> { | |||
93 | /// Something that needs to be proven (by Chalk) during type checking, e.g. that | 93 | /// Something that needs to be proven (by Chalk) during type checking, e.g. that |
94 | /// a certain type implements a certain trait. Proving the Obligation might | 94 | /// a certain type implements a certain trait. Proving the Obligation might |
95 | /// result in additional information about inference variables. | 95 | /// result in additional information about inference variables. |
96 | #[derive(Clone, Debug, PartialEq, Eq)] | 96 | #[derive(Clone, Debug, PartialEq, Eq, Hash)] |
97 | pub enum Obligation { | 97 | pub enum Obligation { |
98 | /// Prove that a certain type implements a trait (the type is the `Self` type | 98 | /// Prove that a certain type implements a trait (the type is the `Self` type |
99 | /// parameter to the `TraitRef`). | 99 | /// parameter to the `TraitRef`). |
@@ -116,11 +116,11 @@ pub struct ProjectionPredicate { | |||
116 | pub ty: Ty, | 116 | pub ty: Ty, |
117 | } | 117 | } |
118 | 118 | ||
119 | /// Check using Chalk whether trait is implemented for given parameters including `Self` type. | 119 | /// Solve a trait goal using Chalk. |
120 | pub(crate) fn implements_query( | 120 | pub(crate) fn solve_query( |
121 | db: &impl HirDatabase, | 121 | db: &impl HirDatabase, |
122 | krate: Crate, | 122 | krate: Crate, |
123 | trait_ref: Canonical<InEnvironment<TraitRef>>, | 123 | trait_ref: Canonical<InEnvironment<Obligation>>, |
124 | ) -> Option<Solution> { | 124 | ) -> Option<Solution> { |
125 | let _p = profile("implements_query"); | 125 | let _p = profile("implements_query"); |
126 | let canonical = trait_ref.to_chalk(db).cast(); | 126 | let canonical = trait_ref.to_chalk(db).cast(); |
@@ -131,19 +131,6 @@ pub(crate) fn implements_query( | |||
131 | solution.map(|solution| solution_from_chalk(db, solution)) | 131 | solution.map(|solution| solution_from_chalk(db, solution)) |
132 | } | 132 | } |
133 | 133 | ||
134 | pub(crate) fn normalize_query( | ||
135 | db: &impl HirDatabase, | ||
136 | krate: Crate, | ||
137 | projection: Canonical<InEnvironment<ProjectionPredicate>>, | ||
138 | ) -> Option<Solution> { | ||
139 | let canonical = projection.to_chalk(db).cast(); | ||
140 | // We currently don't deal with universes (I think / hope they're not yet | ||
141 | // relevant for our use cases?) | ||
142 | let u_canonical = chalk_ir::UCanonical { canonical, universes: 1 }; | ||
143 | let solution = solve(db, krate, &u_canonical); | ||
144 | solution.map(|solution| solution_from_chalk(db, solution)) | ||
145 | } | ||
146 | |||
147 | fn solution_from_chalk(db: &impl HirDatabase, solution: chalk_solve::Solution) -> Solution { | 134 | fn solution_from_chalk(db: &impl HirDatabase, solution: chalk_solve::Solution) -> Solution { |
148 | let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution>| { | 135 | let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution>| { |
149 | let value = subst | 136 | let value = subst |