diff options
author | Florian Diebold <[email protected]> | 2021-04-04 12:07:06 +0100 |
---|---|---|
committer | Florian Diebold <[email protected]> | 2021-04-04 12:16:39 +0100 |
commit | a4d7bdf1c884a9f3dd415a882fa56422adae89bf (patch) | |
tree | 8b5d2db036649ddc15c587a03e1684b3314be50b /crates/hir_ty/src/lower.rs | |
parent | 715c178f0b52117c4c689c39a0921012bfbb2386 (diff) |
Replace Substitution::bound_vars and ::type_params_for_generics
Diffstat (limited to 'crates/hir_ty/src/lower.rs')
-rw-r--r-- | crates/hir_ty/src/lower.rs | 24 |
1 files changed, 8 insertions, 16 deletions
diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 644a2eed5..f9a721fdf 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs | |||
@@ -234,7 +234,7 @@ impl<'a> TyLoweringContext<'a> { | |||
234 | let impl_trait_id = ImplTraitId::ReturnTypeImplTrait(func, idx); | 234 | let impl_trait_id = ImplTraitId::ReturnTypeImplTrait(func, idx); |
235 | let opaque_ty_id = self.db.intern_impl_trait_id(impl_trait_id).into(); | 235 | let opaque_ty_id = self.db.intern_impl_trait_id(impl_trait_id).into(); |
236 | let generics = generics(self.db.upcast(), func.into()); | 236 | let generics = generics(self.db.upcast(), func.into()); |
237 | let parameters = Substitution::bound_vars(&generics, self.in_binders); | 237 | let parameters = generics.bound_vars_subst(self.in_binders); |
238 | TyKind::Alias(AliasTy::Opaque(OpaqueTy { | 238 | TyKind::Alias(AliasTy::Opaque(OpaqueTy { |
239 | opaque_ty_id, | 239 | opaque_ty_id, |
240 | substitution: parameters, | 240 | substitution: parameters, |
@@ -411,24 +411,16 @@ impl<'a> TyLoweringContext<'a> { | |||
411 | TypeNs::SelfType(impl_id) => { | 411 | TypeNs::SelfType(impl_id) => { |
412 | let generics = generics(self.db.upcast(), impl_id.into()); | 412 | let generics = generics(self.db.upcast(), impl_id.into()); |
413 | let substs = match self.type_param_mode { | 413 | let substs = match self.type_param_mode { |
414 | TypeParamLoweringMode::Placeholder => { | 414 | TypeParamLoweringMode::Placeholder => generics.type_params_subst(self.db), |
415 | Substitution::type_params_for_generics(self.db, &generics) | 415 | TypeParamLoweringMode::Variable => generics.bound_vars_subst(self.in_binders), |
416 | } | ||
417 | TypeParamLoweringMode::Variable => { | ||
418 | Substitution::bound_vars(&generics, self.in_binders) | ||
419 | } | ||
420 | }; | 416 | }; |
421 | self.db.impl_self_ty(impl_id).subst(&substs) | 417 | self.db.impl_self_ty(impl_id).subst(&substs) |
422 | } | 418 | } |
423 | TypeNs::AdtSelfType(adt) => { | 419 | TypeNs::AdtSelfType(adt) => { |
424 | let generics = generics(self.db.upcast(), adt.into()); | 420 | let generics = generics(self.db.upcast(), adt.into()); |
425 | let substs = match self.type_param_mode { | 421 | let substs = match self.type_param_mode { |
426 | TypeParamLoweringMode::Placeholder => { | 422 | TypeParamLoweringMode::Placeholder => generics.type_params_subst(self.db), |
427 | Substitution::type_params_for_generics(self.db, &generics) | 423 | TypeParamLoweringMode::Variable => generics.bound_vars_subst(self.in_binders), |
428 | } | ||
429 | TypeParamLoweringMode::Variable => { | ||
430 | Substitution::bound_vars(&generics, self.in_binders) | ||
431 | } | ||
432 | }; | 424 | }; |
433 | self.db.ty(adt.into()).subst(&substs) | 425 | self.db.ty(adt.into()).subst(&substs) |
434 | } | 426 | } |
@@ -1060,7 +1052,7 @@ fn fn_sig_for_fn(db: &dyn HirDatabase, def: FunctionId) -> PolyFnSig { | |||
1060 | /// function body. | 1052 | /// function body. |
1061 | fn type_for_fn(db: &dyn HirDatabase, def: FunctionId) -> Binders<Ty> { | 1053 | fn type_for_fn(db: &dyn HirDatabase, def: FunctionId) -> Binders<Ty> { |
1062 | let generics = generics(db.upcast(), def.into()); | 1054 | let generics = generics(db.upcast(), def.into()); |
1063 | let substs = Substitution::bound_vars(&generics, DebruijnIndex::INNERMOST); | 1055 | let substs = generics.bound_vars_subst(DebruijnIndex::INNERMOST); |
1064 | Binders::new( | 1056 | Binders::new( |
1065 | substs.len(&Interner), | 1057 | substs.len(&Interner), |
1066 | TyKind::FnDef(CallableDefId::FunctionId(def).to_chalk(db), substs).intern(&Interner), | 1058 | TyKind::FnDef(CallableDefId::FunctionId(def).to_chalk(db), substs).intern(&Interner), |
@@ -1105,7 +1097,7 @@ fn type_for_struct_constructor(db: &dyn HirDatabase, def: StructId) -> Binders<T | |||
1105 | return type_for_adt(db, def.into()); | 1097 | return type_for_adt(db, def.into()); |
1106 | } | 1098 | } |
1107 | let generics = generics(db.upcast(), def.into()); | 1099 | let generics = generics(db.upcast(), def.into()); |
1108 | let substs = Substitution::bound_vars(&generics, DebruijnIndex::INNERMOST); | 1100 | let substs = generics.bound_vars_subst(DebruijnIndex::INNERMOST); |
1109 | Binders::new( | 1101 | Binders::new( |
1110 | substs.len(&Interner), | 1102 | substs.len(&Interner), |
1111 | TyKind::FnDef(CallableDefId::StructId(def).to_chalk(db), substs).intern(&Interner), | 1103 | TyKind::FnDef(CallableDefId::StructId(def).to_chalk(db), substs).intern(&Interner), |
@@ -1132,7 +1124,7 @@ fn type_for_enum_variant_constructor(db: &dyn HirDatabase, def: EnumVariantId) - | |||
1132 | return type_for_adt(db, def.parent.into()); | 1124 | return type_for_adt(db, def.parent.into()); |
1133 | } | 1125 | } |
1134 | let generics = generics(db.upcast(), def.parent.into()); | 1126 | let generics = generics(db.upcast(), def.parent.into()); |
1135 | let substs = Substitution::bound_vars(&generics, DebruijnIndex::INNERMOST); | 1127 | let substs = generics.bound_vars_subst(DebruijnIndex::INNERMOST); |
1136 | Binders::new( | 1128 | Binders::new( |
1137 | substs.len(&Interner), | 1129 | substs.len(&Interner), |
1138 | TyKind::FnDef(CallableDefId::EnumVariantId(def).to_chalk(db), substs).intern(&Interner), | 1130 | TyKind::FnDef(CallableDefId::EnumVariantId(def).to_chalk(db), substs).intern(&Interner), |