From 1332e72d09036e31961bb0ab5a7175d34c2fbf68 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Wed, 7 Apr 2021 21:12:42 +0200 Subject: Fix TyBuilder methods --- crates/hir_ty/src/builder.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'crates/hir_ty/src/builder.rs') diff --git a/crates/hir_ty/src/builder.rs b/crates/hir_ty/src/builder.rs index 09512d1ce..9a698898b 100644 --- a/crates/hir_ty/src/builder.rs +++ b/crates/hir_ty/src/builder.rs @@ -4,6 +4,7 @@ use std::iter; use chalk_ir::{ cast::{Cast, CastTo, Caster}, + fold::Fold, interner::HasInterner, AdtId, BoundVar, DebruijnIndex, Safety, Scalar, }; @@ -32,8 +33,7 @@ impl TyBuilder { fn build_internal(self) -> (D, Substitution) { assert_eq!(self.vec.len(), self.param_count); - // FIXME: would be good to have a way to construct a chalk_ir::Substitution from the interned form - let subst = Substitution::intern(self.vec); + let subst = Substitution::from_iter(&Interner, self.vec); (self.data, subst) } @@ -141,7 +141,7 @@ impl TyBuilder { self.vec.push(fallback().cast(&Interner)); } else { // each default can depend on the previous parameters - let subst_so_far = Substitution::intern(self.vec.clone()); + let subst_so_far = Substitution::from_iter(&Interner, self.vec.clone()); self.vec .push(default_ty.clone().substitute(&Interner, &subst_so_far).cast(&Interner)); } @@ -196,13 +196,13 @@ impl TyBuilder { } } -impl> TyBuilder> { +impl + Fold> TyBuilder> { fn subst_binders(b: Binders) -> Self { let param_count = b.binders.len(&Interner); TyBuilder::new(b, param_count) } - pub fn build(self) -> T { + pub fn build(self) -> >::Result { let (b, subst) = self.build_internal(); b.substitute(&Interner, &subst) } -- cgit v1.2.3 From d992736e796501b2a5ae232644924a3dfefede92 Mon Sep 17 00:00:00 2001 From: Florian Diebold Date: Thu, 8 Apr 2021 14:35:15 +0200 Subject: Remove unused --- crates/hir_ty/src/builder.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'crates/hir_ty/src/builder.rs') diff --git a/crates/hir_ty/src/builder.rs b/crates/hir_ty/src/builder.rs index 9a698898b..e25ef866d 100644 --- a/crates/hir_ty/src/builder.rs +++ b/crates/hir_ty/src/builder.rs @@ -14,7 +14,7 @@ use smallvec::SmallVec; use crate::{ db::HirDatabase, primitive, to_assoc_type_id, to_chalk_trait_id, utils::generics, Binders, CallableSig, FnPointer, FnSig, FnSubst, GenericArg, Interner, ProjectionTy, Substitution, - TraitRef, Ty, TyDefId, TyExt, TyKind, TypeWalk, ValueTyDefId, + TraitRef, Ty, TyDefId, TyExt, TyKind, ValueTyDefId, }; /// This is a builder for `Ty` or anything that needs a `Substitution`. -- cgit v1.2.3