aboutsummaryrefslogtreecommitdiff
path: root/crates/hir_ty/src/infer
diff options
context:
space:
mode:
Diffstat (limited to 'crates/hir_ty/src/infer')
-rw-r--r--crates/hir_ty/src/infer/coerce.rs6
-rw-r--r--crates/hir_ty/src/infer/expr.rs37
-rw-r--r--crates/hir_ty/src/infer/pat.rs12
-rw-r--r--crates/hir_ty/src/infer/path.rs20
-rw-r--r--crates/hir_ty/src/infer/unify.rs16
5 files changed, 48 insertions, 43 deletions
diff --git a/crates/hir_ty/src/infer/coerce.rs b/crates/hir_ty/src/infer/coerce.rs
index 137419264..b1f98c507 100644
--- a/crates/hir_ty/src/infer/coerce.rs
+++ b/crates/hir_ty/src/infer/coerce.rs
@@ -7,7 +7,9 @@
7use chalk_ir::{Mutability, TyVariableKind}; 7use chalk_ir::{Mutability, TyVariableKind};
8use hir_def::lang_item::LangItemTarget; 8use hir_def::lang_item::LangItemTarget;
9 9
10use crate::{autoderef, traits::Solution, Interner, Obligation, Substs, TraitRef, Ty, TyKind}; 10use crate::{
11 autoderef, traits::Solution, Interner, Obligation, Substitution, TraitRef, Ty, TyKind,
12};
11 13
12use super::{InEnvironment, InferenceContext}; 14use super::{InEnvironment, InferenceContext};
13 15
@@ -134,7 +136,7 @@ impl<'a> InferenceContext<'a> {
134 return None; 136 return None;
135 } 137 }
136 138
137 let substs = Substs::build_for_generics(&generic_params) 139 let substs = Substitution::build_for_generics(&generic_params)
138 .push(from_ty.clone()) 140 .push(from_ty.clone())
139 .push(to_ty.clone()) 141 .push(to_ty.clone())
140 .build(); 142 .build();
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs
index f40dec17f..0be8c5a90 100644
--- a/crates/hir_ty/src/infer/expr.rs
+++ b/crates/hir_ty/src/infer/expr.rs
@@ -21,8 +21,8 @@ use crate::{
21 to_assoc_type_id, 21 to_assoc_type_id,
22 traits::{chalk::from_chalk, FnTrait, InEnvironment}, 22 traits::{chalk::from_chalk, FnTrait, InEnvironment},
23 utils::{generics, variant_data, Generics}, 23 utils::{generics, variant_data, Generics},
24 AdtId, Binders, CallableDefId, FnPointer, FnSig, Interner, Obligation, Rawness, Scalar, Substs, 24 AdtId, Binders, CallableDefId, FnPointer, FnSig, Interner, Obligation, Rawness, Scalar,
25 TraitRef, Ty, TyKind, 25 Substitution, TraitRef, Ty, TyKind,
26}; 26};
27 27
28use super::{ 28use super::{
@@ -77,7 +77,7 @@ impl<'a> InferenceContext<'a> {
77 return None; 77 return None;
78 } 78 }
79 79
80 let mut param_builder = Substs::builder(num_args); 80 let mut param_builder = Substitution::builder(num_args);
81 let mut arg_tys = vec![]; 81 let mut arg_tys = vec![];
82 for _ in 0..num_args { 82 for _ in 0..num_args {
83 let arg = self.table.new_type_var(); 83 let arg = self.table.new_type_var();
@@ -87,7 +87,7 @@ impl<'a> InferenceContext<'a> {
87 let parameters = param_builder.build(); 87 let parameters = param_builder.build();
88 let arg_ty = TyKind::Tuple(num_args, parameters).intern(&Interner); 88 let arg_ty = TyKind::Tuple(num_args, parameters).intern(&Interner);
89 let substs = 89 let substs =
90 Substs::build_for_generics(&generic_params).push(ty.clone()).push(arg_ty).build(); 90 Substitution::build_for_generics(&generic_params).push(ty.clone()).push(arg_ty).build();
91 91
92 let trait_env = Arc::clone(&self.trait_env); 92 let trait_env = Arc::clone(&self.trait_env);
93 let implements_fn_trait = 93 let implements_fn_trait =
@@ -181,7 +181,7 @@ impl<'a> InferenceContext<'a> {
181 let inner_ty = self.infer_expr(*body, &Expectation::none()); 181 let inner_ty = self.infer_expr(*body, &Expectation::none());
182 let impl_trait_id = crate::ImplTraitId::AsyncBlockTypeImplTrait(self.owner, *body); 182 let impl_trait_id = crate::ImplTraitId::AsyncBlockTypeImplTrait(self.owner, *body);
183 let opaque_ty_id = self.db.intern_impl_trait_id(impl_trait_id).into(); 183 let opaque_ty_id = self.db.intern_impl_trait_id(impl_trait_id).into();
184 TyKind::OpaqueType(opaque_ty_id, Substs::single(inner_ty)).intern(&Interner) 184 TyKind::OpaqueType(opaque_ty_id, Substitution::single(inner_ty)).intern(&Interner)
185 } 185 }
186 Expr::Loop { body, label } => { 186 Expr::Loop { body, label } => {
187 self.breakables.push(BreakableContext { 187 self.breakables.push(BreakableContext {
@@ -262,12 +262,12 @@ impl<'a> InferenceContext<'a> {
262 let sig_ty = TyKind::Function(FnPointer { 262 let sig_ty = TyKind::Function(FnPointer {
263 num_args: sig_tys.len() - 1, 263 num_args: sig_tys.len() - 1,
264 sig: FnSig { abi: (), safety: chalk_ir::Safety::Safe, variadic: false }, 264 sig: FnSig { abi: (), safety: chalk_ir::Safety::Safe, variadic: false },
265 substs: Substs(sig_tys.clone().into()), 265 substs: Substitution(sig_tys.clone().into()),
266 }) 266 })
267 .intern(&Interner); 267 .intern(&Interner);
268 let closure_id = self.db.intern_closure((self.owner, tgt_expr)).into(); 268 let closure_id = self.db.intern_closure((self.owner, tgt_expr)).into();
269 let closure_ty = 269 let closure_ty =
270 TyKind::Closure(closure_id, Substs::single(sig_ty)).intern(&Interner); 270 TyKind::Closure(closure_id, Substitution::single(sig_ty)).intern(&Interner);
271 271
272 // Eagerly try to relate the closure type with the expected 272 // Eagerly try to relate the closure type with the expected
273 // type, otherwise we often won't have enough information to 273 // type, otherwise we often won't have enough information to
@@ -402,7 +402,7 @@ impl<'a> InferenceContext<'a> {
402 402
403 self.unify(&ty, &expected.ty); 403 self.unify(&ty, &expected.ty);
404 404
405 let substs = ty.substs().cloned().unwrap_or_else(Substs::empty); 405 let substs = ty.substs().cloned().unwrap_or_else(Substitution::empty);
406 let field_types = def_id.map(|it| self.db.field_types(it)).unwrap_or_default(); 406 let field_types = def_id.map(|it| self.db.field_types(it)).unwrap_or_default();
407 let variant_data = def_id.map(|it| variant_data(self.db.upcast(), it)); 407 let variant_data = def_id.map(|it| variant_data(self.db.upcast(), it));
408 for field in fields.iter() { 408 for field in fields.iter() {
@@ -511,7 +511,8 @@ impl<'a> InferenceContext<'a> {
511 Expr::Box { expr } => { 511 Expr::Box { expr } => {
512 let inner_ty = self.infer_expr_inner(*expr, &Expectation::none()); 512 let inner_ty = self.infer_expr_inner(*expr, &Expectation::none());
513 if let Some(box_) = self.resolve_boxed_box() { 513 if let Some(box_) = self.resolve_boxed_box() {
514 let mut sb = Substs::builder(generics(self.db.upcast(), box_.into()).len()); 514 let mut sb =
515 Substitution::builder(generics(self.db.upcast(), box_.into()).len());
515 sb = sb.push(inner_ty); 516 sb = sb.push(inner_ty);
516 match self.db.generic_defaults(box_.into()).as_ref() { 517 match self.db.generic_defaults(box_.into()).as_ref() {
517 [_, alloc_ty, ..] if !alloc_ty.value.is_unknown() => { 518 [_, alloc_ty, ..] if !alloc_ty.value.is_unknown() => {
@@ -610,31 +611,31 @@ impl<'a> InferenceContext<'a> {
610 let rhs_ty = rhs.map(|e| self.infer_expr(e, &rhs_expect)); 611 let rhs_ty = rhs.map(|e| self.infer_expr(e, &rhs_expect));
611 match (range_type, lhs_ty, rhs_ty) { 612 match (range_type, lhs_ty, rhs_ty) {
612 (RangeOp::Exclusive, None, None) => match self.resolve_range_full() { 613 (RangeOp::Exclusive, None, None) => match self.resolve_range_full() {
613 Some(adt) => Ty::adt_ty(adt, Substs::empty()), 614 Some(adt) => Ty::adt_ty(adt, Substitution::empty()),
614 None => self.err_ty(), 615 None => self.err_ty(),
615 }, 616 },
616 (RangeOp::Exclusive, None, Some(ty)) => match self.resolve_range_to() { 617 (RangeOp::Exclusive, None, Some(ty)) => match self.resolve_range_to() {
617 Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), 618 Some(adt) => Ty::adt_ty(adt, Substitution::single(ty)),
618 None => self.err_ty(), 619 None => self.err_ty(),
619 }, 620 },
620 (RangeOp::Inclusive, None, Some(ty)) => { 621 (RangeOp::Inclusive, None, Some(ty)) => {
621 match self.resolve_range_to_inclusive() { 622 match self.resolve_range_to_inclusive() {
622 Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), 623 Some(adt) => Ty::adt_ty(adt, Substitution::single(ty)),
623 None => self.err_ty(), 624 None => self.err_ty(),
624 } 625 }
625 } 626 }
626 (RangeOp::Exclusive, Some(_), Some(ty)) => match self.resolve_range() { 627 (RangeOp::Exclusive, Some(_), Some(ty)) => match self.resolve_range() {
627 Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), 628 Some(adt) => Ty::adt_ty(adt, Substitution::single(ty)),
628 None => self.err_ty(), 629 None => self.err_ty(),
629 }, 630 },
630 (RangeOp::Inclusive, Some(_), Some(ty)) => { 631 (RangeOp::Inclusive, Some(_), Some(ty)) => {
631 match self.resolve_range_inclusive() { 632 match self.resolve_range_inclusive() {
632 Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), 633 Some(adt) => Ty::adt_ty(adt, Substitution::single(ty)),
633 None => self.err_ty(), 634 None => self.err_ty(),
634 } 635 }
635 } 636 }
636 (RangeOp::Exclusive, Some(ty), None) => match self.resolve_range_from() { 637 (RangeOp::Exclusive, Some(ty), None) => match self.resolve_range_from() {
637 Some(adt) => Ty::adt_ty(adt, Substs::single(ty)), 638 Some(adt) => Ty::adt_ty(adt, Substitution::single(ty)),
638 None => self.err_ty(), 639 None => self.err_ty(),
639 }, 640 },
640 (RangeOp::Inclusive, _, None) => self.err_ty(), 641 (RangeOp::Inclusive, _, None) => self.err_ty(),
@@ -681,7 +682,7 @@ impl<'a> InferenceContext<'a> {
681 self.infer_expr_coerce(*expr, &Expectation::has_type(ty.clone())); 682 self.infer_expr_coerce(*expr, &Expectation::has_type(ty.clone()));
682 } 683 }
683 684
684 TyKind::Tuple(tys.len(), Substs(tys.into())).intern(&Interner) 685 TyKind::Tuple(tys.len(), Substitution(tys.into())).intern(&Interner)
685 } 686 }
686 Expr::Array(array) => { 687 Expr::Array(array) => {
687 let elem_ty = match expected.ty.interned(&Interner) { 688 let elem_ty = match expected.ty.interned(&Interner) {
@@ -887,7 +888,7 @@ impl<'a> InferenceContext<'a> {
887 def_generics: Option<Generics>, 888 def_generics: Option<Generics>,
888 generic_args: Option<&GenericArgs>, 889 generic_args: Option<&GenericArgs>,
889 receiver_ty: &Ty, 890 receiver_ty: &Ty,
890 ) -> Substs { 891 ) -> Substitution {
891 let (parent_params, self_params, type_params, impl_trait_params) = 892 let (parent_params, self_params, type_params, impl_trait_params) =
892 def_generics.as_ref().map_or((0, 0, 0, 0), |g| g.provenance_split()); 893 def_generics.as_ref().map_or((0, 0, 0, 0), |g| g.provenance_split());
893 assert_eq!(self_params, 0); // method shouldn't have another Self param 894 assert_eq!(self_params, 0); // method shouldn't have another Self param
@@ -926,7 +927,7 @@ impl<'a> InferenceContext<'a> {
926 substs.push(self.err_ty()); 927 substs.push(self.err_ty());
927 } 928 }
928 assert_eq!(substs.len(), total_len); 929 assert_eq!(substs.len(), total_len);
929 Substs(substs.into()) 930 Substitution(substs.into())
930 } 931 }
931 932
932 fn register_obligations_for_call(&mut self, callable_ty: &Ty) { 933 fn register_obligations_for_call(&mut self, callable_ty: &Ty) {
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs
index 9e8ca18ef..befa0d69b 100644
--- a/crates/hir_ty/src/infer/pat.rs
+++ b/crates/hir_ty/src/infer/pat.rs
@@ -12,7 +12,9 @@ use hir_def::{
12use hir_expand::name::Name; 12use hir_expand::name::Name;
13 13
14use super::{BindingMode, Expectation, InferenceContext}; 14use super::{BindingMode, Expectation, InferenceContext};
15use crate::{lower::lower_to_chalk_mutability, utils::variant_data, Interner, Substs, Ty, TyKind}; 15use crate::{
16 lower::lower_to_chalk_mutability, utils::variant_data, Interner, Substitution, Ty, TyKind,
17};
16 18
17impl<'a> InferenceContext<'a> { 19impl<'a> InferenceContext<'a> {
18 fn infer_tuple_struct_pat( 20 fn infer_tuple_struct_pat(
@@ -31,7 +33,7 @@ impl<'a> InferenceContext<'a> {
31 } 33 }
32 self.unify(&ty, expected); 34 self.unify(&ty, expected);
33 35
34 let substs = ty.substs().cloned().unwrap_or_else(Substs::empty); 36 let substs = ty.substs().cloned().unwrap_or_else(Substitution::empty);
35 37
36 let field_tys = def.map(|it| self.db.field_types(it)).unwrap_or_default(); 38 let field_tys = def.map(|it| self.db.field_types(it)).unwrap_or_default();
37 let (pre, post) = match ellipsis { 39 let (pre, post) = match ellipsis {
@@ -70,7 +72,7 @@ impl<'a> InferenceContext<'a> {
70 72
71 self.unify(&ty, expected); 73 self.unify(&ty, expected);
72 74
73 let substs = ty.substs().cloned().unwrap_or_else(Substs::empty); 75 let substs = ty.substs().cloned().unwrap_or_else(Substitution::empty);
74 76
75 let field_tys = def.map(|it| self.db.field_types(it)).unwrap_or_default(); 77 let field_tys = def.map(|it| self.db.field_types(it)).unwrap_or_default();
76 for subpat in subpats { 78 for subpat in subpats {
@@ -138,7 +140,7 @@ impl<'a> InferenceContext<'a> {
138 inner_tys.extend(expectations_iter.by_ref().take(n_uncovered_patterns).cloned()); 140 inner_tys.extend(expectations_iter.by_ref().take(n_uncovered_patterns).cloned());
139 inner_tys.extend(post.iter().zip(expectations_iter).map(infer_pat)); 141 inner_tys.extend(post.iter().zip(expectations_iter).map(infer_pat));
140 142
141 TyKind::Tuple(inner_tys.len(), Substs(inner_tys.into())).intern(&Interner) 143 TyKind::Tuple(inner_tys.len(), Substitution(inner_tys.into())).intern(&Interner)
142 } 144 }
143 Pat::Or(ref pats) => { 145 Pat::Or(ref pats) => {
144 if let Some((first_pat, rest)) = pats.split_first() { 146 if let Some((first_pat, rest)) = pats.split_first() {
@@ -237,7 +239,7 @@ impl<'a> InferenceContext<'a> {
237 }; 239 };
238 240
239 let inner_ty = self.infer_pat(*inner, &inner_expected, default_bm); 241 let inner_ty = self.infer_pat(*inner, &inner_expected, default_bm);
240 Ty::adt_ty(box_adt, Substs::single(inner_ty)) 242 Ty::adt_ty(box_adt, Substitution::single(inner_ty))
241 } 243 }
242 None => self.err_ty(), 244 None => self.err_ty(),
243 }, 245 },
diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs
index af108fb6c..ea01d6238 100644
--- a/crates/hir_ty/src/infer/path.rs
+++ b/crates/hir_ty/src/infer/path.rs
@@ -9,7 +9,7 @@ use hir_def::{
9}; 9};
10use hir_expand::name::Name; 10use hir_expand::name::Name;
11 11
12use crate::{method_resolution, Interner, Substs, Ty, TyKind, ValueTyDefId}; 12use crate::{method_resolution, Interner, Substitution, Ty, TyKind, ValueTyDefId};
13 13
14use super::{ExprOrPatId, InferenceContext, TraitRef}; 14use super::{ExprOrPatId, InferenceContext, TraitRef};
15 15
@@ -79,7 +79,7 @@ impl<'a> InferenceContext<'a> {
79 } 79 }
80 ValueNs::ImplSelf(impl_id) => { 80 ValueNs::ImplSelf(impl_id) => {
81 let generics = crate::utils::generics(self.db.upcast(), impl_id.into()); 81 let generics = crate::utils::generics(self.db.upcast(), impl_id.into());
82 let substs = Substs::type_params_for_generics(self.db, &generics); 82 let substs = Substitution::type_params_for_generics(self.db, &generics);
83 let ty = self.db.impl_self_ty(impl_id).subst(&substs); 83 let ty = self.db.impl_self_ty(impl_id).subst(&substs);
84 if let Some((AdtId::StructId(struct_id), substs)) = ty.as_adt() { 84 if let Some((AdtId::StructId(struct_id), substs)) = ty.as_adt() {
85 let ty = self.db.value_ty(struct_id.into()).subst(&substs); 85 let ty = self.db.value_ty(struct_id.into()).subst(&substs);
@@ -94,10 +94,10 @@ impl<'a> InferenceContext<'a> {
94 94
95 let ty = self.db.value_ty(typable); 95 let ty = self.db.value_ty(typable);
96 // self_subst is just for the parent 96 // self_subst is just for the parent
97 let parent_substs = self_subst.unwrap_or_else(Substs::empty); 97 let parent_substs = self_subst.unwrap_or_else(Substitution::empty);
98 let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver); 98 let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver);
99 let substs = ctx.substs_from_path(path, typable, true); 99 let substs = ctx.substs_from_path(path, typable, true);
100 let full_substs = Substs::builder(substs.len()) 100 let full_substs = Substitution::builder(substs.len())
101 .use_parent_substs(&parent_substs) 101 .use_parent_substs(&parent_substs)
102 .fill(substs.0[parent_substs.len()..].iter().cloned()) 102 .fill(substs.0[parent_substs.len()..].iter().cloned())
103 .build(); 103 .build();
@@ -111,7 +111,7 @@ impl<'a> InferenceContext<'a> {
111 path: &Path, 111 path: &Path,
112 remaining_index: usize, 112 remaining_index: usize,
113 id: ExprOrPatId, 113 id: ExprOrPatId,
114 ) -> Option<(ValueNs, Option<Substs>)> { 114 ) -> Option<(ValueNs, Option<Substitution>)> {
115 assert!(remaining_index < path.segments().len()); 115 assert!(remaining_index < path.segments().len());
116 // there may be more intermediate segments between the resolved one and 116 // there may be more intermediate segments between the resolved one and
117 // the end. Only the last segment needs to be resolved to a value; from 117 // the end. Only the last segment needs to be resolved to a value; from
@@ -164,7 +164,7 @@ impl<'a> InferenceContext<'a> {
164 trait_ref: TraitRef, 164 trait_ref: TraitRef,
165 segment: PathSegment<'_>, 165 segment: PathSegment<'_>,
166 id: ExprOrPatId, 166 id: ExprOrPatId,
167 ) -> Option<(ValueNs, Option<Substs>)> { 167 ) -> Option<(ValueNs, Option<Substitution>)> {
168 let trait_ = trait_ref.trait_; 168 let trait_ = trait_ref.trait_;
169 let item = 169 let item =
170 self.db.trait_data(trait_).items.iter().map(|(_name, id)| (*id)).find_map(|item| { 170 self.db.trait_data(trait_).items.iter().map(|(_name, id)| (*id)).find_map(|item| {
@@ -208,7 +208,7 @@ impl<'a> InferenceContext<'a> {
208 ty: Ty, 208 ty: Ty,
209 name: &Name, 209 name: &Name,
210 id: ExprOrPatId, 210 id: ExprOrPatId,
211 ) -> Option<(ValueNs, Option<Substs>)> { 211 ) -> Option<(ValueNs, Option<Substitution>)> {
212 if let TyKind::Unknown = ty.interned(&Interner) { 212 if let TyKind::Unknown = ty.interned(&Interner) {
213 return None; 213 return None;
214 } 214 }
@@ -241,7 +241,7 @@ impl<'a> InferenceContext<'a> {
241 }; 241 };
242 let substs = match container { 242 let substs = match container {
243 AssocContainerId::ImplId(impl_id) => { 243 AssocContainerId::ImplId(impl_id) => {
244 let impl_substs = Substs::build_for_def(self.db, impl_id) 244 let impl_substs = Substitution::build_for_def(self.db, impl_id)
245 .fill(iter::repeat_with(|| self.table.new_type_var())) 245 .fill(iter::repeat_with(|| self.table.new_type_var()))
246 .build(); 246 .build();
247 let impl_self_ty = self.db.impl_self_ty(impl_id).subst(&impl_substs); 247 let impl_self_ty = self.db.impl_self_ty(impl_id).subst(&impl_substs);
@@ -250,7 +250,7 @@ impl<'a> InferenceContext<'a> {
250 } 250 }
251 AssocContainerId::TraitId(trait_) => { 251 AssocContainerId::TraitId(trait_) => {
252 // we're picking this method 252 // we're picking this method
253 let trait_substs = Substs::build_for_def(self.db, trait_) 253 let trait_substs = Substitution::build_for_def(self.db, trait_)
254 .push(ty.clone()) 254 .push(ty.clone())
255 .fill(std::iter::repeat_with(|| self.table.new_type_var())) 255 .fill(std::iter::repeat_with(|| self.table.new_type_var()))
256 .build(); 256 .build();
@@ -274,7 +274,7 @@ impl<'a> InferenceContext<'a> {
274 ty: &Ty, 274 ty: &Ty,
275 name: &Name, 275 name: &Name,
276 id: ExprOrPatId, 276 id: ExprOrPatId,
277 ) -> Option<(ValueNs, Option<Substs>)> { 277 ) -> Option<(ValueNs, Option<Substitution>)> {
278 let (enum_id, subst) = match ty.as_adt() { 278 let (enum_id, subst) = match ty.as_adt() {
279 Some((AdtId::EnumId(e), subst)) => (e, subst), 279 Some((AdtId::EnumId(e), subst)) => (e, subst),
280 _ => return None, 280 _ => return None,
diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs
index 7795f446f..b2d4f67b3 100644
--- a/crates/hir_ty/src/infer/unify.rs
+++ b/crates/hir_ty/src/infer/unify.rs
@@ -8,7 +8,7 @@ use ena::unify::{InPlaceUnificationTable, NoError, UnifyKey, UnifyValue};
8use super::{InferenceContext, Obligation}; 8use super::{InferenceContext, Obligation};
9use crate::{ 9use crate::{
10 BoundVar, Canonical, DebruijnIndex, FnPointer, GenericPredicate, InEnvironment, InferenceVar, 10 BoundVar, Canonical, DebruijnIndex, FnPointer, GenericPredicate, InEnvironment, InferenceVar,
11 Interner, Scalar, Substs, Ty, TyKind, TypeWalk, 11 Interner, Scalar, Substitution, Ty, TyKind, TypeWalk,
12}; 12};
13 13
14impl<'a> InferenceContext<'a> { 14impl<'a> InferenceContext<'a> {
@@ -123,10 +123,10 @@ impl<T> Canonicalized<T> {
123 pub(super) fn apply_solution( 123 pub(super) fn apply_solution(
124 &self, 124 &self,
125 ctx: &mut InferenceContext<'_>, 125 ctx: &mut InferenceContext<'_>,
126 solution: Canonical<Substs>, 126 solution: Canonical<Substitution>,
127 ) { 127 ) {
128 // the solution may contain new variables, which we need to convert to new inference vars 128 // the solution may contain new variables, which we need to convert to new inference vars
129 let new_vars = Substs( 129 let new_vars = Substitution(
130 solution 130 solution
131 .kinds 131 .kinds
132 .iter() 132 .iter()
@@ -147,9 +147,9 @@ impl<T> Canonicalized<T> {
147 } 147 }
148} 148}
149 149
150pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substs> { 150pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substitution> {
151 let mut table = InferenceTable::new(); 151 let mut table = InferenceTable::new();
152 let vars = Substs( 152 let vars = Substitution(
153 tys.kinds 153 tys.kinds
154 .iter() 154 .iter()
155 // we always use type vars here because we want everything to 155 // we always use type vars here because we want everything to
@@ -173,7 +173,7 @@ pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option<Substs> {
173 } 173 }
174 } 174 }
175 Some( 175 Some(
176 Substs::builder(tys.kinds.len()) 176 Substitution::builder(tys.kinds.len())
177 .fill(vars.iter().map(|v| table.resolve_ty_completely(v.clone()))) 177 .fill(vars.iter().map(|v| table.resolve_ty_completely(v.clone())))
178 .build(), 178 .build(),
179 ) 179 )
@@ -264,8 +264,8 @@ impl InferenceTable {
264 264
265 pub(crate) fn unify_substs( 265 pub(crate) fn unify_substs(
266 &mut self, 266 &mut self,
267 substs1: &Substs, 267 substs1: &Substitution,
268 substs2: &Substs, 268 substs2: &Substitution,
269 depth: usize, 269 depth: usize,
270 ) -> bool { 270 ) -> bool {
271 substs1.0.iter().zip(substs2.0.iter()).all(|(t1, t2)| self.unify_inner(t1, t2, depth)) 271 substs1.0.iter().zip(substs2.0.iter()).all(|(t1, t2)| self.unify_inner(t1, t2, depth))