From 05eba0db3dd76f016aabdd49af6211e70a1812ed Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Mon, 5 Apr 2021 18:39:53 +0200 Subject: Binders::subst -> substitute --- crates/hir/src/display.rs | 2 +- crates/hir/src/lib.rs | 6 +++--- crates/hir/src/source_analyzer.rs | 2 +- crates/hir_ty/src/builder.rs | 4 ++-- crates/hir_ty/src/display.rs | 12 ++++++------ crates/hir_ty/src/infer.rs | 8 ++++---- crates/hir_ty/src/infer/expr.rs | 10 +++++----- crates/hir_ty/src/infer/pat.rs | 4 ++-- crates/hir_ty/src/infer/path.rs | 6 +++--- crates/hir_ty/src/lib.rs | 8 ++++---- crates/hir_ty/src/lower.rs | 8 ++++---- crates/hir_ty/src/method_resolution.rs | 4 ++-- crates/hir_ty/src/traits/chalk/mapping.rs | 2 +- crates/hir_ty/src/utils.rs | 2 +- 14 files changed, 39 insertions(+), 39 deletions(-) (limited to 'crates') diff --git a/crates/hir/src/display.rs b/crates/hir/src/display.rs index 993772aac..d4e477a85 100644 --- a/crates/hir/src/display.rs +++ b/crates/hir/src/display.rs @@ -235,7 +235,7 @@ impl HirDisplay for TypeParam { write!(f, "{}", self.name(f.db))?; let bounds = f.db.generic_predicates_for_param(self.id); let substs = TyBuilder::type_params_subst(f.db, self.id.parent); - let predicates = bounds.iter().cloned().map(|b| b.subst(&substs)).collect::>(); + let predicates = bounds.iter().cloned().map(|b| b.substitute(&substs)).collect::>(); if !(predicates.is_empty() || f.omit_verbose_types()) { write_bounds_like_dyn_trait_with_prefix(":", &predicates, f)?; } diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index ccfe348a4..add1b55c2 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -516,7 +516,7 @@ impl Field { VariantDef::Variant(it) => it.parent.id.into(), }; let substs = TyBuilder::type_params_subst(db, generic_def_id); - let ty = db.field_types(var_id)[self.id].clone().subst(&substs); + let ty = db.field_types(var_id)[self.id].clone().substitute(&substs); Type::new(db, self.parent.module(db).id.krate(), var_id, ty) } @@ -1503,7 +1503,7 @@ impl TypeParam { let krate = self.id.parent.module(db.upcast()).krate(); let ty = params.get(local_idx)?.clone(); let subst = TyBuilder::type_params_subst(db, self.id.parent); - let ty = ty.subst(&subst.prefix(local_idx)); + let ty = ty.substitute(&subst.prefix(local_idx)); Some(Type::new_with_resolver_inner(db, krate, &resolver, ty)) } } @@ -1916,7 +1916,7 @@ impl Type { .iter() .map(|(local_id, ty)| { let def = Field { parent: variant_id.into(), id: local_id }; - let ty = ty.clone().subst(substs); + let ty = ty.clone().substitute(substs); (def, self.derived(ty)) }) .collect() diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index 8e9ea0a03..82807ea09 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -339,7 +339,7 @@ impl SourceAnalyzer { .into_iter() .map(|local_id| { let field = FieldId { parent: variant, local_id }; - let ty = field_types[local_id].clone().subst(substs); + let ty = field_types[local_id].clone().substitute(substs); (field.into(), Type::new_with_resolver_inner(db, krate, &self.resolver, ty)) }) .collect() diff --git a/crates/hir_ty/src/builder.rs b/crates/hir_ty/src/builder.rs index 7b8603fd7..c5196200c 100644 --- a/crates/hir_ty/src/builder.rs +++ b/crates/hir_ty/src/builder.rs @@ -139,7 +139,7 @@ impl TyBuilder { } else { // each default can depend on the previous parameters let subst_so_far = Substitution::intern(self.vec.clone()); - self.vec.push(default_ty.clone().subst(&subst_so_far).cast(&Interner)); + self.vec.push(default_ty.clone().substitute(&subst_so_far).cast(&Interner)); } } self @@ -200,7 +200,7 @@ impl> TyBuilder> { pub fn build(self) -> T { let (b, subst) = self.build_internal(); - b.subst(&subst) + b.substitute(&subst) } } diff --git a/crates/hir_ty/src/display.rs b/crates/hir_ty/src/display.rs index 2e178e5a8..704504b02 100644 --- a/crates/hir_ty/src/display.rs +++ b/crates/hir_ty/src/display.rs @@ -352,7 +352,7 @@ impl HirDisplay for Ty { let data = (*datas) .as_ref() .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); - let bounds = data.subst(parameters); + let bounds = data.substitute(parameters); bounds.into_value_and_skipped_binders().0 } else { Vec::new() @@ -397,7 +397,7 @@ impl HirDisplay for Ty { } TyKind::FnDef(def, parameters) => { let def = from_chalk(f.db, *def); - let sig = f.db.callable_item_signature(def).subst(parameters); + let sig = f.db.callable_item_signature(def).substitute(parameters); match def { CallableDefId::FunctionId(ff) => { write!(f, "fn {}", f.db.function_data(ff).name)? @@ -482,7 +482,7 @@ impl HirDisplay for Ty { (_, Some(default_parameter)) => { let actual_default = default_parameter .clone() - .subst(¶meters.prefix(i)); + .substitute(¶meters.prefix(i)); if parameter.assert_ty_ref(&Interner) != &actual_default { default_from = i + 1; @@ -542,7 +542,7 @@ impl HirDisplay for Ty { let data = (*datas) .as_ref() .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); - let bounds = data.subst(¶meters); + let bounds = data.substitute(¶meters); write_bounds_like_dyn_trait_with_prefix("impl", bounds.skip_binders(), f)?; // FIXME: it would maybe be good to distinguish this from the alias type (when debug printing), and to show the substitution } @@ -595,7 +595,7 @@ impl HirDisplay for Ty { let bounds = f.db.generic_predicates(id.parent) .into_iter() - .map(|pred| pred.clone().subst(&substs)) + .map(|pred| pred.clone().substitute(&substs)) .filter(|wc| match &wc.skip_binders() { WhereClause::Implemented(tr) => { tr.self_type_parameter(&Interner) == self @@ -629,7 +629,7 @@ impl HirDisplay for Ty { let data = (*datas) .as_ref() .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); - let bounds = data.subst(&opaque_ty.substitution); + let bounds = data.substitute(&opaque_ty.substitution); write_bounds_like_dyn_trait_with_prefix("impl", bounds.skip_binders(), f)?; } ImplTraitId::AsyncBlockTypeImplTrait(..) => { diff --git a/crates/hir_ty/src/infer.rs b/crates/hir_ty/src/infer.rs index 6151e48cd..a87037344 100644 --- a/crates/hir_ty/src/infer.rs +++ b/crates/hir_ty/src/infer.rs @@ -470,25 +470,25 @@ impl<'a> InferenceContext<'a> { TypeNs::AdtId(AdtId::StructId(strukt)) => { let substs = ctx.substs_from_path(path, strukt.into(), true); let ty = self.db.ty(strukt.into()); - let ty = self.insert_type_vars(ty.subst(&substs)); + let ty = self.insert_type_vars(ty.substitute(&substs)); forbid_unresolved_segments((ty, Some(strukt.into())), unresolved) } TypeNs::AdtId(AdtId::UnionId(u)) => { let substs = ctx.substs_from_path(path, u.into(), true); let ty = self.db.ty(u.into()); - let ty = self.insert_type_vars(ty.subst(&substs)); + let ty = self.insert_type_vars(ty.substitute(&substs)); forbid_unresolved_segments((ty, Some(u.into())), unresolved) } TypeNs::EnumVariantId(var) => { let substs = ctx.substs_from_path(path, var.into(), true); let ty = self.db.ty(var.parent.into()); - let ty = self.insert_type_vars(ty.subst(&substs)); + let ty = self.insert_type_vars(ty.substitute(&substs)); forbid_unresolved_segments((ty, Some(var.into())), unresolved) } TypeNs::SelfType(impl_id) => { let generics = crate::utils::generics(self.db.upcast(), impl_id.into()); let substs = generics.type_params_subst(self.db); - let ty = self.db.impl_self_ty(impl_id).subst(&substs); + let ty = self.db.impl_self_ty(impl_id).substitute(&substs); match unresolved { None => { let variant = ty_variant(&ty); diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index d61ef65f2..5f8ad2174 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> { self.result.record_field_resolutions.insert(field.expr, field_def); } let field_ty = field_def.map_or(self.err_ty(), |it| { - field_types[it.local_id].clone().subst(&substs) + field_types[it.local_id].clone().substitute(&substs) }); self.infer_expr_coerce(field.expr, &Expectation::has_type(field_ty)); } @@ -462,7 +462,7 @@ impl<'a> InferenceContext<'a> { Some( self.db.field_types((*s).into())[field.local_id] .clone() - .subst(¶meters), + .substitute(¶meters), ) } else { None @@ -476,7 +476,7 @@ impl<'a> InferenceContext<'a> { Some( self.db.field_types((*u).into())[field.local_id] .clone() - .subst(¶meters), + .substitute(¶meters), ) } else { None @@ -852,7 +852,7 @@ impl<'a> InferenceContext<'a> { None => (receiver_ty, Binders::empty(&Interner, self.err_ty()), None), }; let substs = self.substs_for_method_call(def_generics, generic_args, &derefed_receiver_ty); - let method_ty = method_ty.subst(&substs); + let method_ty = method_ty.substitute(&substs); let method_ty = self.insert_type_vars(method_ty); self.register_obligations_for_call(&method_ty); let (expected_receiver_ty, param_tys, ret_ty) = match method_ty.callable_sig(self.db) { @@ -950,7 +950,7 @@ impl<'a> InferenceContext<'a> { let generic_predicates = self.db.generic_predicates(def.into()); for predicate in generic_predicates.iter() { let (predicate, binders) = - predicate.clone().subst(parameters).into_value_and_skipped_binders(); + predicate.clone().substitute(parameters).into_value_and_skipped_binders(); always!(binders.len(&Interner) == 0); // quantified where clauses not yet handled self.push_obligation(predicate.cast(&Interner)); } diff --git a/crates/hir_ty/src/infer/pat.rs b/crates/hir_ty/src/infer/pat.rs index 469f37dd9..b74f1f4f8 100644 --- a/crates/hir_ty/src/infer/pat.rs +++ b/crates/hir_ty/src/infer/pat.rs @@ -49,7 +49,7 @@ impl<'a> InferenceContext<'a> { let expected_ty = var_data .as_ref() .and_then(|d| d.field(&Name::new_tuple_field(i))) - .map_or(self.err_ty(), |field| field_tys[field].clone().subst(&substs)); + .map_or(self.err_ty(), |field| field_tys[field].clone().substitute(&substs)); let expected_ty = self.normalize_associated_types_in(expected_ty); self.infer_pat(subpat, &expected_ty, default_bm); } @@ -84,7 +84,7 @@ impl<'a> InferenceContext<'a> { } let expected_ty = matching_field - .map_or(self.err_ty(), |field| field_tys[field].clone().subst(&substs)); + .map_or(self.err_ty(), |field| field_tys[field].clone().substitute(&substs)); let expected_ty = self.normalize_associated_types_in(expected_ty); self.infer_pat(subpat.pat, &expected_ty, default_bm); } diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs index 89d78e781..5e3a45766 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> { ValueNs::ImplSelf(impl_id) => { let generics = crate::utils::generics(self.db.upcast(), impl_id.into()); let substs = generics.type_params_subst(self.db); - let ty = self.db.impl_self_ty(impl_id).subst(&substs); + let ty = self.db.impl_self_ty(impl_id).substitute(&substs); if let Some((AdtId::StructId(struct_id), substs)) = ty.as_adt() { - let ty = self.db.value_ty(struct_id.into()).subst(&substs); + let ty = self.db.value_ty(struct_id.into()).substitute(&substs); return Some(ty); } else { // FIXME: diagnostic, invalid Self reference @@ -243,7 +243,7 @@ impl<'a> InferenceContext<'a> { let impl_substs = TyBuilder::subst_for_def(self.db, impl_id) .fill(iter::repeat_with(|| self.table.new_type_var())) .build(); - let impl_self_ty = self.db.impl_self_ty(impl_id).subst(&impl_substs); + let impl_self_ty = self.db.impl_self_ty(impl_id).substitute(&impl_substs); self.unify(&impl_self_ty, &ty); Some(impl_substs) } diff --git a/crates/hir_ty/src/lib.rs b/crates/hir_ty/src/lib.rs index 86973c7ed..e15840c9a 100644 --- a/crates/hir_ty/src/lib.rs +++ b/crates/hir_ty/src/lib.rs @@ -130,7 +130,7 @@ impl Binders { impl Binders { /// Substitutes all variables. - pub fn subst(self, subst: &Substitution) -> T { + pub fn substitute(self, subst: &Substitution) -> T { let (value, binders) = self.into_value_and_skipped_binders(); assert_eq!(subst.len(&Interner), binders.len(&Interner)); value.subst_bound_vars(subst) @@ -362,7 +362,7 @@ impl Ty { TyKind::FnDef(def, parameters) => { let callable_def = db.lookup_intern_callable_def((*def).into()); let sig = db.callable_item_signature(callable_def); - Some(sig.subst(¶meters)) + Some(sig.substitute(¶meters)) } TyKind::Closure(.., substs) => { let sig_param = substs.at(&Interner, 0).assert_ty_ref(&Interner); @@ -436,7 +436,7 @@ impl Ty { let data = (*it) .as_ref() .map(|rpit| rpit.impl_traits[idx as usize].bounds.clone()); - data.subst(&opaque_ty.substitution) + data.substitute(&opaque_ty.substitution) }) } // It always has an parameter for Future::Output type. @@ -455,7 +455,7 @@ impl Ty { let predicates = db .generic_predicates(id.parent) .into_iter() - .map(|pred| pred.clone().subst(&substs)) + .map(|pred| pred.clone().substitute(&substs)) .filter(|wc| match &wc.skip_binders() { WhereClause::Implemented(tr) => { tr.self_type_parameter(&Interner) == self diff --git a/crates/hir_ty/src/lower.rs b/crates/hir_ty/src/lower.rs index 59d2a157f..6a3a880e0 100644 --- a/crates/hir_ty/src/lower.rs +++ b/crates/hir_ty/src/lower.rs @@ -414,7 +414,7 @@ impl<'a> TyLoweringContext<'a> { TypeParamLoweringMode::Placeholder => generics.type_params_subst(self.db), TypeParamLoweringMode::Variable => generics.bound_vars_subst(self.in_binders), }; - self.db.impl_self_ty(impl_id).subst(&substs) + self.db.impl_self_ty(impl_id).substitute(&substs) } TypeNs::AdtSelfType(adt) => { let generics = generics(self.db.upcast(), adt.into()); @@ -422,7 +422,7 @@ impl<'a> TyLoweringContext<'a> { TypeParamLoweringMode::Placeholder => generics.type_params_subst(self.db), TypeParamLoweringMode::Variable => generics.bound_vars_subst(self.in_binders), }; - self.db.ty(adt.into()).subst(&substs) + self.db.ty(adt.into()).substitute(&substs) } TypeNs::AdtId(it) => self.lower_path_inner(resolved_segment, it.into(), infer_args), @@ -516,7 +516,7 @@ impl<'a> TyLoweringContext<'a> { TyDefId::TypeAliasId(it) => Some(it.into()), }; let substs = self.substs_from_path_segment(segment, generic_def, infer_args, None); - self.db.ty(typeable).subst(&substs) + self.db.ty(typeable).substitute(&substs) } /// Collect generic arguments from a path into a `Substs`. See also @@ -620,7 +620,7 @@ impl<'a> TyLoweringContext<'a> { for default_ty in defaults.iter().skip(substs.len()) { // each default can depend on the previous parameters let substs_so_far = Substitution::from_iter(&Interner, substs.clone()); - substs.push(default_ty.clone().subst(&substs_so_far)); + substs.push(default_ty.clone().substitute(&substs_so_far)); } } } diff --git a/crates/hir_ty/src/method_resolution.rs b/crates/hir_ty/src/method_resolution.rs index ad5022808..88750acf3 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( let vars = TyBuilder::subst_for_def(db, impl_id) .fill_with_bound_vars(DebruijnIndex::INNERMOST, self_ty.binders.len(&Interner)) .build(); - let self_ty_with_vars = db.impl_self_ty(impl_id).subst(&vars); + let self_ty_with_vars = db.impl_self_ty(impl_id).substitute(&vars); let mut kinds = self_ty.binders.interned().to_vec(); kinds.extend( iter::repeat(chalk_ir::WithKind::new( @@ -774,7 +774,7 @@ fn transform_receiver_ty( AssocContainerId::ModuleId(_) => unreachable!(), }; let sig = db.callable_item_signature(function_id.into()); - Some(sig.map(|s| s.params()[0].clone()).subst(&substs)) + Some(sig.map(|s| s.params()[0].clone()).substitute(&substs)) } 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 2c7407c7c..481b0bb10 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( let generic_predicates = db.generic_predicates(def); let mut result = Vec::with_capacity(generic_predicates.len()); for pred in generic_predicates.iter() { - result.push(pred.clone().subst(substs).to_chalk(db)); + result.push(pred.clone().substitute(substs).to_chalk(db)); } result } diff --git a/crates/hir_ty/src/utils.rs b/crates/hir_ty/src/utils.rs index df0ea4368..a63075a19 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 None, }) }) - .map(|pred| pred.subst(&trait_ref.substitution)) + .map(|pred| pred.substitute(&trait_ref.substitution)) .collect() } -- cgit v1.2.3