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(-) 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