aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/autoderef.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2021-03-20 11:47:50 +0000
committerGitHub <[email protected]>2021-03-20 11:47:50 +0000
commit4d67032bbb3e1f97ee7af43cb6f056d01f791ca2 (patch)
tree70a77a26ca09d8d5cd843b1cd9d59af229cd0daf /crates/hir_ty/src/autoderef.rs
parent5ac0290f533eed295c6e92564d7530d41cf45d6e (diff)
parent7ec3b66f7a3ac0a33cf435bc3596fdac542fc52a (diff)
Merge #8117
8117: Turn Obligation into something similar to chalk_ir::DomainGoal r=flodiebold a=flodiebold This includes starting to make use of Chalk's `Cast` trait. Co-authored-by: Florian Diebold <[email protected]>
Diffstat (limited to 'crates/hir_ty/src/autoderef.rs')
-rw-r--r--crates/hir_ty/src/autoderef.rs9
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 @@
6use std::iter::successors; 6use std::iter::successors;
7 7
8use base_db::CrateId; 8use base_db::CrateId;
9use chalk_ir::cast::Cast;
9use hir_def::lang_item::LangItemTarget; 10use hir_def::lang_item::LangItemTarget;
10use hir_expand::name::name; 11use hir_expand::name::name;
11use log::{info, warn}; 12use 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
22const AUTODEREF_RECURSION_LIMIT: usize = 10; 23const 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