diff options
author | Florian Diebold <[email protected]> | 2021-03-20 10:23:59 +0000 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-03-20 11:47:12 +0000 |
commit | 7ec3b66f7a3ac0a33cf435bc3596fdac542fc52a (patch) | |
tree | 70a77a26ca09d8d5cd843b1cd9d59af229cd0daf /crates/hir_ty/src/autoderef.rs | |
parent | 8e7e405f6ab0c1ee10bfdd3d55a97628fe4cd6dd (diff) |
Turn Obligation into something similar to chalk_ir::DomainGoal
This includes starting to make use of Chalk's `Cast` trait.
Diffstat (limited to 'crates/hir_ty/src/autoderef.rs')
-rw-r--r-- | crates/hir_ty/src/autoderef.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/crates/hir_ty/src/autoderef.rs b/crates/hir_ty/src/autoderef.rs index 33b966026..23ab042c1 100644 --- a/crates/hir_ty/src/autoderef.rs +++ b/crates/hir_ty/src/autoderef.rs | |||
@@ -6,6 +6,7 @@ | |||
6 | use std::iter::successors; | 6 | use std::iter::successors; |
7 | 7 | ||
8 | use base_db::CrateId; | 8 | use base_db::CrateId; |
9 | use chalk_ir::cast::Cast; | ||
9 | use hir_def::lang_item::LangItemTarget; | 10 | use hir_def::lang_item::LangItemTarget; |
10 | use hir_expand::name::name; | 11 | use hir_expand::name::name; |
11 | use log::{info, warn}; | 12 | use log::{info, warn}; |
@@ -15,8 +16,8 @@ use crate::{ | |||
15 | to_assoc_type_id, to_chalk_trait_id, | 16 | to_assoc_type_id, to_chalk_trait_id, |
16 | traits::{InEnvironment, Solution}, | 17 | traits::{InEnvironment, Solution}, |
17 | utils::generics, | 18 | utils::generics, |
18 | AliasEq, AliasTy, BoundVar, Canonical, DebruijnIndex, Interner, Obligation, ProjectionTy, | 19 | AliasEq, AliasTy, BoundVar, Canonical, DebruijnIndex, Interner, ProjectionTy, Substitution, |
19 | Substitution, TraitRef, Ty, TyKind, | 20 | TraitRef, Ty, TyKind, |
20 | }; | 21 | }; |
21 | 22 | ||
22 | const AUTODEREF_RECURSION_LIMIT: usize = 10; | 23 | const AUTODEREF_RECURSION_LIMIT: usize = 10; |
@@ -74,7 +75,7 @@ fn deref_by_trait( | |||
74 | let implements_goal = Canonical { | 75 | let implements_goal = Canonical { |
75 | kinds: ty.value.kinds.clone(), | 76 | kinds: ty.value.kinds.clone(), |
76 | value: InEnvironment { | 77 | value: InEnvironment { |
77 | value: Obligation::Trait(trait_ref), | 78 | value: trait_ref.cast(&Interner), |
78 | environment: ty.environment.clone(), | 79 | environment: ty.environment.clone(), |
79 | }, | 80 | }, |
80 | }; | 81 | }; |
@@ -92,7 +93,7 @@ fn deref_by_trait( | |||
92 | .intern(&Interner), | 93 | .intern(&Interner), |
93 | }; | 94 | }; |
94 | 95 | ||
95 | let obligation = super::Obligation::AliasEq(projection); | 96 | let obligation = projection.cast(&Interner); |
96 | 97 | ||
97 | let in_env = InEnvironment { value: obligation, environment: ty.environment }; | 98 | let in_env = InEnvironment { value: obligation, environment: ty.environment }; |
98 | 99 | ||