From 584d1c9e5bc39402e2855d0ffa9394ae5a066060 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Sun, 4 Apr 2021 12:48:10 +0200 Subject: Replace last uses of SubstsBuilder by TyBuilder --- crates/hir_ty/src/infer/expr.rs | 3 +-- crates/hir_ty/src/infer/path.rs | 5 +---- crates/hir_ty/src/infer/unify.rs | 13 +++++-------- 3 files changed, 7 insertions(+), 14 deletions(-) (limited to 'crates/hir_ty/src/infer') diff --git a/crates/hir_ty/src/infer/expr.rs b/crates/hir_ty/src/infer/expr.rs index 9f5624eb0..c584a2c08 100644 --- a/crates/hir_ty/src/infer/expr.rs +++ b/crates/hir_ty/src/infer/expr.rs @@ -75,14 +75,13 @@ impl<'a> InferenceContext<'a> { self.db.trait_data(fn_once_trait).associated_type_by_name(&name![Output])?; let mut arg_tys = vec![]; - let parameters = Substitution::builder(num_args) + let arg_ty = TyBuilder::tuple(num_args) .fill(repeat_with(|| { let arg = self.table.new_type_var(); arg_tys.push(arg.clone()); arg })) .build(); - let arg_ty = TyKind::Tuple(num_args, parameters).intern(&Interner); let projection = { let b = TyBuilder::assoc_type_projection(self.db, output_assoc_type); diff --git a/crates/hir_ty/src/infer/path.rs b/crates/hir_ty/src/infer/path.rs index c9219776b..d55ae4900 100644 --- a/crates/hir_ty/src/infer/path.rs +++ b/crates/hir_ty/src/infer/path.rs @@ -93,16 +93,13 @@ impl<'a> InferenceContext<'a> { ValueNs::GenericParam(it) => return Some(self.db.const_param_ty(it)), }; - let ty = self.db.value_ty(typable); - // self_subst is just for the parent let parent_substs = self_subst.unwrap_or_else(|| Substitution::empty(&Interner)); let ctx = crate::lower::TyLoweringContext::new(self.db, &self.resolver); let substs = ctx.substs_from_path(path, typable, true); - let full_substs = Substitution::builder(substs.len(&Interner)) + let ty = TyBuilder::value_ty(self.db, typable) .use_parent_substs(&parent_substs) .fill(substs.interned(&Interner)[parent_substs.len(&Interner)..].iter().cloned()) .build(); - let ty = ty.subst(&full_substs); Some(ty) } diff --git a/crates/hir_ty/src/infer/unify.rs b/crates/hir_ty/src/infer/unify.rs index d2496db3b..a04b935ef 100644 --- a/crates/hir_ty/src/infer/unify.rs +++ b/crates/hir_ty/src/infer/unify.rs @@ -186,14 +186,11 @@ pub(crate) fn unify(tys: &Canonical<(Ty, Ty)>) -> Option { ); } } - Some( - Substitution::builder(tys.binders.len(&Interner)) - .fill( - vars.iter(&Interner) - .map(|v| table.resolve_ty_completely(v.assert_ty_ref(&Interner).clone())), - ) - .build(), - ) + Some(Substitution::from_iter( + &Interner, + vars.iter(&Interner) + .map(|v| table.resolve_ty_completely(v.assert_ty_ref(&Interner).clone())), + )) } #[derive(Clone, Debug)] -- cgit v1.2.3