aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer.rs
diff options
context:
space:
mode:
authorFlorian Diebold <[email protected]>2021-03-20 10:23:59 +0000
committerFlorian Diebold <[email protected]>2021-03-20 11:47:12 +0000
commit7ec3b66f7a3ac0a33cf435bc3596fdac542fc52a (patch)
tree70a77a26ca09d8d5cd843b1cd9d59af229cd0daf /crates/hir_ty/src/infer.rs
parent8e7e405f6ab0c1ee10bfdd3d55a97628fe4cd6dd (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/infer.rs')
-rw-r--r--crates/hir_ty/src/infer.rs12
1 files changed, 6 insertions, 6 deletions
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs
index 82186979a..b9e434c78 100644
--- a/crates/hir_ty/src/infer.rs
+++ b/crates/hir_ty/src/infer.rs
@@ -18,7 +18,7 @@ use std::mem;
18use std::ops::Index; 18use std::ops::Index;
19use std::sync::Arc; 19use std::sync::Arc;
20 20
21use chalk_ir::Mutability; 21use chalk_ir::{cast::Cast, Mutability};
22use hir_def::{ 22use hir_def::{
23 body::Body, 23 body::Body,
24 data::{ConstData, FunctionData, StaticData}, 24 data::{ConstData, FunctionData, StaticData},
@@ -37,7 +37,7 @@ use stdx::impl_from;
37use syntax::SmolStr; 37use syntax::SmolStr;
38 38
39use super::{ 39use super::{
40 traits::{Guidance, Obligation, Solution}, 40 traits::{DomainGoal, Guidance, Solution},
41 InEnvironment, ProjectionTy, Substitution, TraitEnvironment, TraitRef, Ty, TypeWalk, 41 InEnvironment, ProjectionTy, Substitution, TraitEnvironment, TraitRef, Ty, TypeWalk,
42}; 42};
43use crate::{ 43use crate::{
@@ -204,7 +204,7 @@ struct InferenceContext<'a> {
204 resolver: Resolver, 204 resolver: Resolver,
205 table: unify::InferenceTable, 205 table: unify::InferenceTable,
206 trait_env: Arc<TraitEnvironment>, 206 trait_env: Arc<TraitEnvironment>,
207 obligations: Vec<Obligation>, 207 obligations: Vec<DomainGoal>,
208 result: InferenceResult, 208 result: InferenceResult,
209 /// The return type of the function being inferred, or the closure if we're 209 /// The return type of the function being inferred, or the closure if we're
210 /// currently within one. 210 /// currently within one.
@@ -403,8 +403,8 @@ impl<'a> InferenceContext<'a> {
403 }), 403 }),
404 ty: ty.clone(), 404 ty: ty.clone(),
405 }; 405 };
406 self.obligations.push(Obligation::Trait(trait_ref)); 406 self.obligations.push(trait_ref.cast(&Interner));
407 self.obligations.push(Obligation::AliasEq(alias_eq)); 407 self.obligations.push(alias_eq.cast(&Interner));
408 self.resolve_ty_as_possible(ty) 408 self.resolve_ty_as_possible(ty)
409 } 409 }
410 None => self.err_ty(), 410 None => self.err_ty(),
@@ -430,7 +430,7 @@ impl<'a> InferenceContext<'a> {
430 fn normalize_projection_ty(&mut self, proj_ty: ProjectionTy) -> Ty { 430 fn normalize_projection_ty(&mut self, proj_ty: ProjectionTy) -> Ty {
431 let var = self.table.new_type_var(); 431 let var = self.table.new_type_var();
432 let alias_eq = AliasEq { alias: AliasTy::Projection(proj_ty), ty: var.clone() }; 432 let alias_eq = AliasEq { alias: AliasTy::Projection(proj_ty), ty: var.clone() };
433 let obligation = Obligation::AliasEq(alias_eq); 433 let obligation = alias_eq.cast(&Interner);
434 self.obligations.push(obligation); 434 self.obligations.push(obligation);
435 var 435 var
436 } 436 }