diff options
author | Florian Diebold <[email protected]> | 2021-04-05 17:49:26 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-05 18:21:01 +0100 |
commit | 30a339e038bfd94d8c91f79287be9b7db4f0cb4e (patch) | |
tree | 7e026ded541b94f2908d61a8037ed62f2df91625 /crates/hir_ty | |
parent | 05eba0db3dd76f016aabdd49af6211e70a1812ed (diff) |
Add Interner parameter to Binders::substitute
Diffstat (limited to 'crates/hir_ty')
-rw-r--r-- | crates/hir_ty/src/builder.rs | 5 | ||||
-rw-r--r-- | crates/hir_ty/src/display.rs | 12 | ||||
-rw-r--r-- | crates/hir_ty/src/infer.rs | 8 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/expr.rs | 14 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/pat.rs | 9 | ||||
-rw-r--r-- | crates/hir_ty/src/infer/path.rs | 7 | ||||
-rw-r--r-- | crates/hir_ty/src/lib.rs | 10 | ||||
-rw-r--r-- | crates/hir_ty/src/lower.rs | 8 | ||||
-rw-r--r-- | crates/hir_ty/src/method_resolution.rs | 4 | ||||
-rw-r--r-- | crates/hir_ty/src/traits/chalk/mapping.rs | 2 | ||||
-rw-r--r-- | crates/hir_ty/src/utils.rs | 2 |
11 files changed, 44 insertions, 37 deletions
diff --git a/crates/hir_ty/src/builder.rs b/crates/hir_ty/src/builder.rs index c5196200c..9b2c6975a 100644 --- a/crates/hir_ty/src/builder.rs +++ b/crates/hir_ty/src/builder.rs | |||
@@ -139,7 +139,8 @@ impl TyBuilder<hir_def::AdtId> { | |||
139 | } else { | 139 | } else { |
140 | // each default can depend on the previous parameters | 140 | // each default can depend on the previous parameters |
141 | let subst_so_far = Substitution::intern(self.vec.clone()); | 141 | let subst_so_far = Substitution::intern(self.vec.clone()); |
142 | self.vec.push(default_ty.clone().substitute(&subst_so_far).cast(&Interner)); | 142 | self.vec |
143 | .push(default_ty.clone().substitute(&Interner, &subst_so_far).cast(&Interner)); | ||
143 | } | 144 | } |
144 | } | 145 | } |
145 | self | 146 | self |
@@ -200,7 +201,7 @@ impl<T: TypeWalk + HasInterner<Interner = Interner>> TyBuilder<Binders<T>> { | |||
200 | 201 | ||
201 | pub fn build(self) -> T { | 202 | pub fn build(self) -> T { |
202 | let (b, subst) = self.build_internal(); | 203 | let (b, subst) = self.build_internal(); |
203 | b.substitute(&subst) | 204 | b.substitute(&Interner, &subst) |
204 | } | 205 | } |
205 | } | 206 | } |
206 | 207 | ||
diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 704504b02..f31e6b108 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs | |||
@@ -352,7 +352,7 @@ impl HirDisplay for Ty { | |||
352 | let data = (*datas) | 352 | let data = (*datas) |
353 | .as_ref() | 353 | .as_ref() |
354 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); | 354 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); |
355 | let bounds = data.substitute(parameters); | 355 | let bounds = data.substitute(&Interner, parameters); |
356 | bounds.into_value_and_skipped_binders().0 | 356 | bounds.into_value_and_skipped_binders().0 |
357 | } else { | 357 | } else { |
358 | Vec::new() | 358 | Vec::new() |
@@ -397,7 +397,7 @@ impl HirDisplay for Ty { | |||
397 | } | 397 | } |
398 | TyKind::FnDef(def, parameters) => { | 398 | TyKind::FnDef(def, parameters) => { |
399 | let def = from_chalk(f.db, *def); | 399 | let def = from_chalk(f.db, *def); |
400 | let sig = f.db.callable_item_signature(def).substitute(parameters); | 400 | let sig = f.db.callable_item_signature(def).substitute(&Interner, parameters); |
401 | match def { | 401 | match def { |
402 | CallableDefId::FunctionId(ff) => { | 402 | CallableDefId::FunctionId(ff) => { |
403 | write!(f, "fn {}", f.db.function_data(ff).name)? | 403 | write!(f, "fn {}", f.db.function_data(ff).name)? |
@@ -482,7 +482,7 @@ impl HirDisplay for Ty { | |||
482 | (_, Some(default_parameter)) => { | 482 | (_, Some(default_parameter)) => { |
483 | let actual_default = default_parameter | 483 | let actual_default = default_parameter |
484 | .clone() | 484 | .clone() |
485 | .substitute(¶meters.prefix(i)); | 485 | .substitute(&Interner, ¶meters.prefix(i)); |
486 | if parameter.assert_ty_ref(&Interner) != &actual_default | 486 | if parameter.assert_ty_ref(&Interner) != &actual_default |
487 | { | 487 | { |
488 | default_from = i + 1; | 488 | default_from = i + 1; |
@@ -542,7 +542,7 @@ impl HirDisplay for Ty { | |||
542 | let data = (*datas) | 542 | let data = (*datas) |
543 | .as_ref() | 543 | .as_ref() |
544 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); | 544 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); |
545 | let bounds = data.substitute(¶meters); | 545 | let bounds = data.substitute(&Interner, ¶meters); |
546 | write_bounds_like_dyn_trait_with_prefix("impl", bounds.skip_binders(), f)?; | 546 | write_bounds_like_dyn_trait_with_prefix("impl", bounds.skip_binders(), f)?; |
547 | // FIXME: it would maybe be good to distinguish this from the alias type (when debug printing), and to show the substitution | 547 | // FIXME: it would maybe be good to distinguish this from the alias type (when debug printing), and to show the substitution |
548 | } | 548 | } |
@@ -595,7 +595,7 @@ impl HirDisplay for Ty { | |||
595 | let bounds = | 595 | let bounds = |
596 | f.db.generic_predicates(id.parent) | 596 | f.db.generic_predicates(id.parent) |
597 | .into_iter() | 597 | .into_iter() |
598 | .map(|pred| pred.clone().substitute(&substs)) | 598 | .map(|pred| pred.clone().substitute(&Interner, &substs)) |
599 | .filter(|wc| match &wc.skip_binders() { | 599 | .filter(|wc| match &wc.skip_binders() { |
600 | WhereClause::Implemented(tr) => { | 600 | WhereClause::Implemented(tr) => { |
601 | tr.self_type_parameter(&Interner) == self | 601 | tr.self_type_parameter(&Interner) == self |
@@ -629,7 +629,7 @@ impl HirDisplay for Ty { | |||
629 | let data = (*datas) | 629 | let data = (*datas) |
630 | .as_ref() | 630 | .as_ref() |
631 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); | 631 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); |
632 | let bounds = data.substitute(&opaque_ty.substitution); | 632 | let bounds = data.substitute(&Interner, &opaque_ty.substitution); |
633 | write_bounds_like_dyn_trait_with_prefix("impl", bounds.skip_binders(), f)?; | 633 | write_bounds_like_dyn_trait_with_prefix("impl", bounds.skip_binders(), f)?; |
634 | } | 634 | } |
635 | ImplTraitId::AsyncBlockTypeImplTrait(..) => { | 635 | ImplTraitId::AsyncBlockTypeImplTrait(..) => { |
diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index a87037344..1c3faf5cb 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs | |||
@@ -470,25 +470,25 @@ impl<'a> InferenceContext<'a> { | |||
470 | TypeNs::AdtId(AdtId::StructId(strukt)) => { | 470 | TypeNs::AdtId(AdtId::StructId(strukt)) => { |
471 | let substs = ctx.substs_from_path(path, strukt.into(), true); | 471 | let substs = ctx.substs_from_path(path, strukt.into(), true); |
472 | let ty = self.db.ty(strukt.into()); | 472 | let ty = self.db.ty(strukt.into()); |
473 | let ty = self.insert_type_vars(ty.substitute(&substs)); | 473 | let ty = self.insert_type_vars(ty.substitute(&Interner, &substs)); |
474 | forbid_unresolved_segments((ty, Some(strukt.into())), unresolved) | 474 | forbid_unresolved_segments((ty, Some(strukt.into())), unresolved) |
475 | } | 475 | } |
476 | TypeNs::AdtId(AdtId::UnionId(u)) => { | 476 | TypeNs::AdtId(AdtId::UnionId(u)) => { |
477 | let substs = ctx.substs_from_path(path, u.into(), true); | 477 | let substs = ctx.substs_from_path(path, u.into(), true); |
478 | let ty = self.db.ty(u.into()); | 478 | let ty = self.db.ty(u.into()); |
479 | let ty = self.insert_type_vars(ty.substitute(&substs)); | 479 | let ty = self.insert_type_vars(ty.substitute(&Interner, &substs)); |
480 | forbid_unresolved_segments((ty, Some(u.into())), unresolved) | 480 | forbid_unresolved_segments((ty, Some(u.into())), unresolved) |
481 | } | 481 | } |
482 | TypeNs::EnumVariantId(var) => { | 482 | TypeNs::EnumVariantId(var) => { |
483 | let substs = ctx.substs_from_path(path, var.into(), true); | 483 | let substs = ctx.substs_from_path(path, var.into(), true); |
484 | let ty = self.db.ty(var.parent.into()); | 484 | let ty = self.db.ty(var.parent.into()); |
485 | let ty = self.insert_type_vars(ty.substitute(&substs)); | 485 | let ty = self.insert_type_vars(ty.substitute(&Interner, &substs)); |
486 | forbid_unresolved_segments((ty, Some(var.into())), unresolved) | 486 | forbid_unresolved_segments((ty, Some(var.into())), unresolved) |
487 | } | 487 | } |
488 | TypeNs::SelfType(impl_id) => { | 488 | TypeNs::SelfType(impl_id) => { |
489 | let generics = crate::utils::generics(self.db.upcast(), impl_id.into()); | 489 | let generics = crate::utils::generics(self.db.upcast(), impl_id.into()); |
490 | let substs = generics.type_params_subst(self.db); | 490 | let substs = generics.type_params_subst(self.db); |
491 | let ty = self.db.impl_self_ty(impl_id).substitute(&substs); | 491 | let ty = self.db.impl_self_ty(impl_id).substitute(&Interner, &substs); |
492 | match unresolved { | 492 | match unresolved { |
493 | None => { | 493 | None => { |
494 | let variant = ty_variant(&ty); | 494 | let variant = ty_variant(&ty); |
diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 5f8ad2174..6966d26e7 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs | |||
@@ -419,7 +419,7 @@ impl<'a> InferenceContext<'a> { | |||
419 | self.result.record_field_resolutions.insert(field.expr, field_def); | 419 | self.result.record_field_resolutions.insert(field.expr, field_def); |
420 | } | 420 | } |
421 | let field_ty = field_def.map_or(self.err_ty(), |it| { | 421 | let field_ty = field_def.map_or(self.err_ty(), |it| { |
422 | field_types[it.local_id].clone().substitute(&substs) | 422 | field_types[it.local_id].clone().substitute(&Interner, &substs) |
423 | }); | 423 | }); |
424 | self.infer_expr_coerce(field.expr, &Expectation::has_type(field_ty)); | 424 | self.infer_expr_coerce(field.expr, &Expectation::has_type(field_ty)); |
425 | } | 425 | } |
@@ -462,7 +462,7 @@ impl<'a> InferenceContext<'a> { | |||
462 | Some( | 462 | Some( |
463 | self.db.field_types((*s).into())[field.local_id] | 463 | self.db.field_types((*s).into())[field.local_id] |
464 | .clone() | 464 | .clone() |
465 | .substitute(¶meters), | 465 | .substitute(&Interner, ¶meters), |
466 | ) | 466 | ) |
467 | } else { | 467 | } else { |
468 | None | 468 | None |
@@ -476,7 +476,7 @@ impl<'a> InferenceContext<'a> { | |||
476 | Some( | 476 | Some( |
477 | self.db.field_types((*u).into())[field.local_id] | 477 | self.db.field_types((*u).into())[field.local_id] |
478 | .clone() | 478 | .clone() |
479 | .substitute(¶meters), | 479 | .substitute(&Interner, ¶meters), |
480 | ) | 480 | ) |
481 | } else { | 481 | } else { |
482 | None | 482 | None |
@@ -852,7 +852,7 @@ impl<'a> InferenceContext<'a> { | |||
852 | None => (receiver_ty, Binders::empty(&Interner, self.err_ty()), None), | 852 | None => (receiver_ty, Binders::empty(&Interner, self.err_ty()), None), |
853 | }; | 853 | }; |
854 | let substs = self.substs_for_method_call(def_generics, generic_args, &derefed_receiver_ty); | 854 | let substs = self.substs_for_method_call(def_generics, generic_args, &derefed_receiver_ty); |
855 | let method_ty = method_ty.substitute(&substs); | 855 | let method_ty = method_ty.substitute(&Interner, &substs); |
856 | let method_ty = self.insert_type_vars(method_ty); | 856 | let method_ty = self.insert_type_vars(method_ty); |
857 | self.register_obligations_for_call(&method_ty); | 857 | self.register_obligations_for_call(&method_ty); |
858 | let (expected_receiver_ty, param_tys, ret_ty) = match method_ty.callable_sig(self.db) { | 858 | let (expected_receiver_ty, param_tys, ret_ty) = match method_ty.callable_sig(self.db) { |
@@ -949,8 +949,10 @@ impl<'a> InferenceContext<'a> { | |||
949 | let def: CallableDefId = from_chalk(self.db, *fn_def); | 949 | let def: CallableDefId = from_chalk(self.db, *fn_def); |
950 | let generic_predicates = self.db.generic_predicates(def.into()); | 950 | let generic_predicates = self.db.generic_predicates(def.into()); |
951 | for predicate in generic_predicates.iter() { | 951 | for predicate in generic_predicates.iter() { |
952 | let (predicate, binders) = | 952 | let (predicate, binders) = predicate |
953 | predicate.clone().substitute(parameters).into_value_and_skipped_binders(); | 953 | .clone() |
954 | .substitute(&Interner, parameters) | ||
955 | .into_value_and_skipped_binders(); | ||
954 | always!(binders.len(&Interner) == 0); // quantified where clauses not yet handled | 956 | always!(binders.len(&Interner) == 0); // quantified where clauses not yet handled |
955 | self.push_obligation(predicate.cast(&Interner)); | 957 | self.push_obligation(predicate.cast(&Interner)); |
956 | } | 958 | } |
diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index b74f1f4f8..252ae914a 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs | |||
@@ -49,7 +49,9 @@ impl<'a> InferenceContext<'a> { | |||
49 | let expected_ty = var_data | 49 | let expected_ty = var_data |
50 | .as_ref() | 50 | .as_ref() |
51 | .and_then(|d| d.field(&Name::new_tuple_field(i))) | 51 | .and_then(|d| d.field(&Name::new_tuple_field(i))) |
52 | .map_or(self.err_ty(), |field| field_tys[field].clone().substitute(&substs)); | 52 | .map_or(self.err_ty(), |field| { |
53 | field_tys[field].clone().substitute(&Interner, &substs) | ||
54 | }); | ||
53 | let expected_ty = self.normalize_associated_types_in(expected_ty); | 55 | let expected_ty = self.normalize_associated_types_in(expected_ty); |
54 | self.infer_pat(subpat, &expected_ty, default_bm); | 56 | self.infer_pat(subpat, &expected_ty, default_bm); |
55 | } | 57 | } |
@@ -83,8 +85,9 @@ impl<'a> InferenceContext<'a> { | |||
83 | self.result.record_pat_field_resolutions.insert(subpat.pat, field_def); | 85 | self.result.record_pat_field_resolutions.insert(subpat.pat, field_def); |
84 | } | 86 | } |
85 | 87 | ||
86 | let expected_ty = matching_field | 88 | let expected_ty = matching_field.map_or(self.err_ty(), |field| { |
87 | .map_or(self.err_ty(), |field| field_tys[field].clone().substitute(&substs)); | 89 | field_tys[field].clone().substitute(&Interner, &substs) |
90 | }); | ||
88 | let expected_ty = self.normalize_associated_types_in(expected_ty); | 91 | let expected_ty = self.normalize_associated_types_in(expected_ty); |
89 | self.infer_pat(subpat.pat, &expected_ty, default_bm); | 92 | self.infer_pat(subpat.pat, &expected_ty, default_bm); |
90 | } | 93 | } |
diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs index 5e3a45766..14f705173 100644 --- a/crates/hir_ty/src/infer/path.rs +++ b/crates/hir_ty/src/infer/path.rs | |||
@@ -81,9 +81,9 @@ impl<'a> InferenceContext<'a> { | |||
81 | ValueNs::ImplSelf(impl_id) => { | 81 | ValueNs::ImplSelf(impl_id) => { |
82 | let generics = crate::utils::generics(self.db.upcast(), impl_id.into()); | 82 | let generics = crate::utils::generics(self.db.upcast(), impl_id.into()); |
83 | let substs = generics.type_params_subst(self.db); | 83 | let substs = generics.type_params_subst(self.db); |
84 | let ty = self.db.impl_self_ty(impl_id).substitute(&substs); | 84 | let ty = self.db.impl_self_ty(impl_id).substitute(&Interner, &substs); |
85 | if let Some((AdtId::StructId(struct_id), substs)) = ty.as_adt() { | 85 | if let Some((AdtId::StructId(struct_id), substs)) = ty.as_adt() { |
86 | let ty = self.db.value_ty(struct_id.into()).substitute(&substs); | 86 | let ty = self.db.value_ty(struct_id.into()).substitute(&Interner, &substs); |
87 | return Some(ty); | 87 | return Some(ty); |
88 | } else { | 88 | } else { |
89 | // FIXME: diagnostic, invalid Self reference | 89 | // FIXME: diagnostic, invalid Self reference |
@@ -243,7 +243,8 @@ impl<'a> InferenceContext<'a> { | |||
243 | let impl_substs = TyBuilder::subst_for_def(self.db, impl_id) | 243 | let impl_substs = TyBuilder::subst_for_def(self.db, impl_id) |
244 | .fill(iter::repeat_with(|| self.table.new_type_var())) | 244 | .fill(iter::repeat_with(|| self.table.new_type_var())) |
245 | .build(); | 245 | .build(); |
246 | let impl_self_ty = self.db.impl_self_ty(impl_id).substitute(&impl_substs); | 246 | let impl_self_ty = |
247 | self.db.impl_self_ty(impl_id).substitute(&Interner, &impl_substs); | ||
247 | self.unify(&impl_self_ty, &ty); | 248 | self.unify(&impl_self_ty, &ty); |
248 | Some(impl_substs) | 249 | Some(impl_substs) |
249 | } | 250 | } |
diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index e15840c9a..827317fce 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs | |||
@@ -130,9 +130,9 @@ impl<T> Binders<T> { | |||
130 | 130 | ||
131 | impl<T: TypeWalk> Binders<T> { | 131 | impl<T: TypeWalk> Binders<T> { |
132 | /// Substitutes all variables. | 132 | /// Substitutes all variables. |
133 | pub fn substitute(self, subst: &Substitution) -> T { | 133 | pub fn substitute(self, interner: &Interner, subst: &Substitution) -> T { |
134 | let (value, binders) = self.into_value_and_skipped_binders(); | 134 | let (value, binders) = self.into_value_and_skipped_binders(); |
135 | assert_eq!(subst.len(&Interner), binders.len(&Interner)); | 135 | assert_eq!(subst.len(interner), binders.len(interner)); |
136 | value.subst_bound_vars(subst) | 136 | value.subst_bound_vars(subst) |
137 | } | 137 | } |
138 | } | 138 | } |
@@ -362,7 +362,7 @@ impl Ty { | |||
362 | TyKind::FnDef(def, parameters) => { | 362 | TyKind::FnDef(def, parameters) => { |
363 | let callable_def = db.lookup_intern_callable_def((*def).into()); | 363 | let callable_def = db.lookup_intern_callable_def((*def).into()); |
364 | let sig = db.callable_item_signature(callable_def); | 364 | let sig = db.callable_item_signature(callable_def); |
365 | Some(sig.substitute(¶meters)) | 365 | Some(sig.substitute(&Interner, ¶meters)) |
366 | } | 366 | } |
367 | TyKind::Closure(.., substs) => { | 367 | TyKind::Closure(.., substs) => { |
368 | let sig_param = substs.at(&Interner, 0).assert_ty_ref(&Interner); | 368 | let sig_param = substs.at(&Interner, 0).assert_ty_ref(&Interner); |
@@ -436,7 +436,7 @@ impl Ty { | |||
436 | let data = (*it) | 436 | let data = (*it) |
437 | .as_ref() | 437 | .as_ref() |
438 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); | 438 | .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); |
439 | data.substitute(&opaque_ty.substitution) | 439 | data.substitute(&Interner, &opaque_ty.substitution) |
440 | }) | 440 | }) |
441 | } | 441 | } |
442 | // It always has an parameter for Future::Output type. | 442 | // It always has an parameter for Future::Output type. |
@@ -455,7 +455,7 @@ impl Ty { | |||
455 | let predicates = db | 455 | let predicates = db |
456 | .generic_predicates(id.parent) | 456 | .generic_predicates(id.parent) |
457 | .into_iter() | 457 | .into_iter() |
458 | .map(|pred| pred.clone().substitute(&substs)) | 458 | .map(|pred| pred.clone().substitute(&Interner, &substs)) |
459 | .filter(|wc| match &wc.skip_binders() { | 459 | .filter(|wc| match &wc.skip_binders() { |
460 | WhereClause::Implemented(tr) => { | 460 | WhereClause::Implemented(tr) => { |
461 | tr.self_type_parameter(&Interner) == self | 461 | tr.self_type_parameter(&Interner) == self |
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 6a3a880e0..00838b298 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -414,7 +414,7 @@ impl<'a> TyLoweringContext<'a> { | |||
414 | TypeParamLoweringMode::Placeholder => generics.type_params_subst(self.db), | 414 | TypeParamLoweringMode::Placeholder => generics.type_params_subst(self.db), |
415 | TypeParamLoweringMode::Variable => generics.bound_vars_subst(self.in_binders), | 415 | TypeParamLoweringMode::Variable => generics.bound_vars_subst(self.in_binders), |
416 | }; | 416 | }; |
417 | self.db.impl_self_ty(impl_id).substitute(&substs) | 417 | self.db.impl_self_ty(impl_id).substitute(&Interner, &substs) |
418 | } | 418 | } |
419 | TypeNs::AdtSelfType(adt) => { | 419 | TypeNs::AdtSelfType(adt) => { |
420 | let generics = generics(self.db.upcast(), adt.into()); | 420 | let generics = generics(self.db.upcast(), adt.into()); |
@@ -422,7 +422,7 @@ impl<'a> TyLoweringContext<'a> { | |||
422 | TypeParamLoweringMode::Placeholder => generics.type_params_subst(self.db), | 422 | TypeParamLoweringMode::Placeholder => generics.type_params_subst(self.db), |
423 | TypeParamLoweringMode::Variable => generics.bound_vars_subst(self.in_binders), | 423 | TypeParamLoweringMode::Variable => generics.bound_vars_subst(self.in_binders), |
424 | }; | 424 | }; |
425 | self.db.ty(adt.into()).substitute(&substs) | 425 | self.db.ty(adt.into()).substitute(&Interner, &substs) |
426 | } | 426 | } |
427 | 427 | ||
428 | TypeNs::AdtId(it) => self.lower_path_inner(resolved_segment, it.into(), infer_args), | 428 | TypeNs::AdtId(it) => self.lower_path_inner(resolved_segment, it.into(), infer_args), |
@@ -516,7 +516,7 @@ impl<'a> TyLoweringContext<'a> { | |||
516 | TyDefId::TypeAliasId(it) => Some(it.into()), | 516 | TyDefId::TypeAliasId(it) => Some(it.into()), |
517 | }; | 517 | }; |
518 | let substs = self.substs_from_path_segment(segment, generic_def, infer_args, None); | 518 | let substs = self.substs_from_path_segment(segment, generic_def, infer_args, None); |
519 | self.db.ty(typeable).substitute(&substs) | 519 | self.db.ty(typeable).substitute(&Interner, &substs) |
520 | } | 520 | } |
521 | 521 | ||
522 | /// Collect generic arguments from a path into a `Substs`. See also | 522 | /// Collect generic arguments from a path into a `Substs`. See also |
@@ -620,7 +620,7 @@ impl<'a> TyLoweringContext<'a> { | |||
620 | for default_ty in defaults.iter().skip(substs.len()) { | 620 | for default_ty in defaults.iter().skip(substs.len()) { |
621 | // each default can depend on the previous parameters | 621 | // each default can depend on the previous parameters |
622 | let substs_so_far = Substitution::from_iter(&Interner, substs.clone()); | 622 | let substs_so_far = Substitution::from_iter(&Interner, substs.clone()); |
623 | substs.push(default_ty.clone().substitute(&substs_so_far)); | 623 | substs.push(default_ty.clone().substitute(&Interner, &substs_so_far)); |
624 | } | 624 | } |
625 | } | 625 | } |
626 | } | 626 | } |
diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index 88750acf3..19a1fa793 100644 --- a/crates/hir_ty/src/method_resolution.rs +++ b/crates/hir_ty/src/method_resolution.rs | |||
@@ -712,7 +712,7 @@ pub(crate) fn inherent_impl_substs( | |||
712 | let vars = TyBuilder::subst_for_def(db, impl_id) | 712 | let vars = TyBuilder::subst_for_def(db, impl_id) |
713 | .fill_with_bound_vars(DebruijnIndex::INNERMOST, self_ty.binders.len(&Interner)) | 713 | .fill_with_bound_vars(DebruijnIndex::INNERMOST, self_ty.binders.len(&Interner)) |
714 | .build(); | 714 | .build(); |
715 | let self_ty_with_vars = db.impl_self_ty(impl_id).substitute(&vars); | 715 | let self_ty_with_vars = db.impl_self_ty(impl_id).substitute(&Interner, &vars); |
716 | let mut kinds = self_ty.binders.interned().to_vec(); | 716 | let mut kinds = self_ty.binders.interned().to_vec(); |
717 | kinds.extend( | 717 | kinds.extend( |
718 | iter::repeat(chalk_ir::WithKind::new( | 718 | iter::repeat(chalk_ir::WithKind::new( |
@@ -774,7 +774,7 @@ fn transform_receiver_ty( | |||
774 | AssocContainerId::ModuleId(_) => unreachable!(), | 774 | AssocContainerId::ModuleId(_) => unreachable!(), |
775 | }; | 775 | }; |
776 | let sig = db.callable_item_signature(function_id.into()); | 776 | let sig = db.callable_item_signature(function_id.into()); |
777 | Some(sig.map(|s| s.params()[0].clone()).substitute(&substs)) | 777 | Some(sig.map(|s| s.params()[0].clone()).substitute(&Interner, &substs)) |
778 | } | 778 | } |
779 | 779 | ||
780 | pub fn implements_trait( | 780 | pub fn implements_trait( |
diff --git a/crates/hir_ty/src/traits/chalk/mapping.rs b/crates/hir_ty/src/traits/chalk/mapping.rs index 481b0bb10..9db2b0c2f 100644 --- a/crates/hir_ty/src/traits/chalk/mapping.rs +++ b/crates/hir_ty/src/traits/chalk/mapping.rs | |||
@@ -519,7 +519,7 @@ pub(super) fn convert_where_clauses( | |||
519 | let generic_predicates = db.generic_predicates(def); | 519 | let generic_predicates = db.generic_predicates(def); |
520 | let mut result = Vec::with_capacity(generic_predicates.len()); | 520 | let mut result = Vec::with_capacity(generic_predicates.len()); |
521 | for pred in generic_predicates.iter() { | 521 | for pred in generic_predicates.iter() { |
522 | result.push(pred.clone().substitute(substs).to_chalk(db)); | 522 | result.push(pred.clone().substitute(&Interner, substs).to_chalk(db)); |
523 | } | 523 | } |
524 | result | 524 | result |
525 | } | 525 | } |
diff --git a/crates/hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs index a63075a19..c7786a199 100644 --- a/crates/hir_ty/src/utils.rs +++ b/crates/hir_ty/src/utils.rs | |||
@@ -72,7 +72,7 @@ fn direct_super_trait_refs(db: &dyn HirDatabase, trait_ref: &TraitRef) -> Vec<Tr | |||
72 | _ => None, | 72 | _ => None, |
73 | }) | 73 | }) |
74 | }) | 74 | }) |
75 | .map(|pred| pred.substitute(&trait_ref.substitution)) | 75 | .map(|pred| pred.substitute(&Interner, &trait_ref.substitution)) |
76 | .collect() | 76 | .collect() |
77 | } | 77 | } |
78 | 78 | ||