diff options
Diffstat (limited to 'crates/ra_hir_ty/src/traits.rs')
-rw-r--r-- | crates/ra_hir_ty/src/traits.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/crates/ra_hir_ty/src/traits.rs b/crates/ra_hir_ty/src/traits.rs index 76189a60b..c4dc857bc 100644 --- a/crates/ra_hir_ty/src/traits.rs +++ b/crates/ra_hir_ty/src/traits.rs | |||
@@ -1,7 +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 chalk_ir::{cast::Cast, family::ChalkIr}; | 4 | use chalk_ir::cast::Cast; |
5 | use hir_def::{expr::ExprId, DefWithBodyId, ImplId, TraitId, TypeAliasId}; | 5 | use hir_def::{expr::ExprId, DefWithBodyId, ImplId, TraitId, TypeAliasId}; |
6 | use log::debug; | 6 | use log::debug; |
7 | use ra_db::{impl_intern_key, salsa, CrateId}; | 7 | use ra_db::{impl_intern_key, salsa, CrateId}; |
@@ -12,14 +12,15 @@ use crate::db::HirDatabase; | |||
12 | 12 | ||
13 | use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk}; | 13 | use super::{Canonical, GenericPredicate, HirDisplay, ProjectionTy, TraitRef, Ty, TypeWalk}; |
14 | 14 | ||
15 | use self::chalk::{from_chalk, ToChalk}; | 15 | use self::chalk::{from_chalk, ToChalk, TypeFamily}; |
16 | 16 | ||
17 | pub(crate) mod chalk; | 17 | pub(crate) mod chalk; |
18 | mod builtin; | ||
18 | 19 | ||
19 | #[derive(Debug, Clone)] | 20 | #[derive(Debug, Clone)] |
20 | pub struct TraitSolver { | 21 | pub struct TraitSolver { |
21 | krate: CrateId, | 22 | krate: CrateId, |
22 | inner: Arc<Mutex<chalk_solve::Solver<ChalkIr>>>, | 23 | inner: Arc<Mutex<chalk_solve::Solver<TypeFamily>>>, |
23 | } | 24 | } |
24 | 25 | ||
25 | /// We need eq for salsa | 26 | /// We need eq for salsa |
@@ -35,8 +36,8 @@ impl TraitSolver { | |||
35 | fn solve( | 36 | fn solve( |
36 | &self, | 37 | &self, |
37 | db: &impl HirDatabase, | 38 | db: &impl HirDatabase, |
38 | goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<ChalkIr>>>, | 39 | goal: &chalk_ir::UCanonical<chalk_ir::InEnvironment<chalk_ir::Goal<TypeFamily>>>, |
39 | ) -> Option<chalk_solve::Solution<ChalkIr>> { | 40 | ) -> Option<chalk_solve::Solution<TypeFamily>> { |
40 | let context = ChalkContext { db, krate: self.krate }; | 41 | let context = ChalkContext { db, krate: self.krate }; |
41 | debug!("solve goal: {:?}", goal); | 42 | debug!("solve goal: {:?}", goal); |
42 | let mut solver = match self.inner.lock() { | 43 | let mut solver = match self.inner.lock() { |
@@ -200,17 +201,17 @@ pub(crate) fn trait_solve_query( | |||
200 | 201 | ||
201 | fn solution_from_chalk( | 202 | fn solution_from_chalk( |
202 | db: &impl HirDatabase, | 203 | db: &impl HirDatabase, |
203 | solution: chalk_solve::Solution<ChalkIr>, | 204 | solution: chalk_solve::Solution<TypeFamily>, |
204 | ) -> Solution { | 205 | ) -> Solution { |
205 | let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<ChalkIr>>| { | 206 | let convert_subst = |subst: chalk_ir::Canonical<chalk_ir::Substitution<TypeFamily>>| { |
206 | let value = subst | 207 | let value = subst |
207 | .value | 208 | .value |
208 | .parameters | 209 | .parameters |
209 | .into_iter() | 210 | .into_iter() |
210 | .map(|p| { | 211 | .map(|p| { |
211 | let ty = match p { | 212 | let ty = match p.ty() { |
212 | chalk_ir::Parameter(chalk_ir::ParameterKind::Ty(ty)) => from_chalk(db, ty), | 213 | Some(ty) => from_chalk(db, ty.clone()), |
213 | chalk_ir::Parameter(chalk_ir::ParameterKind::Lifetime(_)) => unimplemented!(), | 214 | None => unimplemented!(), |
214 | }; | 215 | }; |
215 | ty | 216 | ty |
216 | }) | 217 | }) |
@@ -290,7 +291,7 @@ impl FnTrait { | |||
290 | } | 291 | } |
291 | } | 292 | } |
292 | 293 | ||
293 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 294 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
294 | pub struct ClosureFnTraitImplData { | 295 | pub struct ClosureFnTraitImplData { |
295 | def: DefWithBodyId, | 296 | def: DefWithBodyId, |
296 | expr: ExprId, | 297 | expr: ExprId, |
@@ -299,7 +300,7 @@ pub struct ClosureFnTraitImplData { | |||
299 | 300 | ||
300 | /// An impl. Usually this comes from an impl block, but some built-in types get | 301 | /// An impl. Usually this comes from an impl block, but some built-in types get |
301 | /// synthetic impls. | 302 | /// synthetic impls. |
302 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | 303 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
303 | pub enum Impl { | 304 | pub enum Impl { |
304 | /// A normal impl from an impl block. | 305 | /// A normal impl from an impl block. |
305 | ImplBlock(ImplId), | 306 | ImplBlock(ImplId), |