diff --git a/chalk-solve/src/clauses/generalize.rs b/chalk-solve/src/clauses/generalize.rs index f841a8ec68d..91391ae4ca1 100644 --- a/chalk-solve/src/clauses/generalize.rs +++ b/chalk-solve/src/clauses/generalize.rs @@ -9,8 +9,8 @@ use chalk_ir::{ fold::{Fold, Folder}, interner::{HasInterner, Interner}, - Binders, BoundVar, DebruijnIndex, Fallible, Lifetime, LifetimeData, NoSolution, Ty, TyKind, - TyVariableKind, VariableKind, VariableKinds, + Binders, BoundVar, Const, ConstData, ConstValue, DebruijnIndex, Fallible, Lifetime, + LifetimeData, NoSolution, Ty, TyKind, TyVariableKind, VariableKind, VariableKinds, }; use rustc_hash::FxHashMap; @@ -63,6 +63,26 @@ impl Folder for Generalize { Ok(TyKind::BoundVar(new_var).intern(self.interner())) } + fn fold_free_var_const( + &mut self, + ty: Ty, + bound_var: BoundVar, + outer_binder: DebruijnIndex, + ) -> Fallible> { + let binder_vec = &mut self.binders; + let new_index = self.mapping.entry(bound_var).or_insert_with(|| { + let i = binder_vec.len(); + binder_vec.push(VariableKind::Const(ty.clone())); + i + }); + let new_var = BoundVar::new(outer_binder, *new_index); + Ok(ConstData { + ty, + value: ConstValue::BoundVar(new_var), + } + .intern(self.interner())) + } + fn fold_free_var_lifetime( &mut self, bound_var: BoundVar,