From 0a4ba8a8a8d142c7680a4acc1af005e47925b608 Mon Sep 17 00:00:00 2001 From: LeSeulArtichaut Date: Wed, 19 May 2021 19:33:19 +0200 Subject: [PATCH] Introduce `Folder::Error` --- chalk-derive/src/lib.rs | 6 +- chalk-engine/src/normalize_deep.rs | 4 +- chalk-engine/src/strand.rs | 8 +- chalk-ir/src/fold.rs | 104 +++++++++++++------------ chalk-ir/src/fold/binder_impls.rs | 18 ++--- chalk-ir/src/fold/boring_impls.rs | 86 ++++++++++---------- chalk-ir/src/fold/shift.rs | 8 +- chalk-ir/src/fold/subst.rs | 4 +- chalk-ir/src/lib.rs | 4 +- chalk-solve/src/clauses/generalize.rs | 8 +- chalk-solve/src/infer/canonicalize.rs | 4 +- chalk-solve/src/infer/invert.rs | 4 +- chalk-solve/src/infer/ucanonicalize.rs | 8 +- chalk-solve/src/infer/unify.rs | 4 +- 14 files changed, 150 insertions(+), 120 deletions(-) diff --git a/chalk-derive/src/lib.rs b/chalk-derive/src/lib.rs index e8a127d778a..4929bacdeb9 100644 --- a/chalk-derive/src/lib.rs +++ b/chalk-derive/src/lib.rs @@ -295,11 +295,11 @@ fn derive_fold(mut s: synstructure::Structure) -> TokenStream { quote! { type Result = #result; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn ::chalk_ir::fold::Folder < 'i, #interner >, + folder: &mut dyn ::chalk_ir::fold::Folder < 'i, #interner, Error = E >, outer_binder: ::chalk_ir::DebruijnIndex, - ) -> ::chalk_ir::Fallible + ) -> ::std::result::Result where #interner: 'i, { diff --git a/chalk-engine/src/normalize_deep.rs b/chalk-engine/src/normalize_deep.rs index 4690ffceeab..20d2ed354d5 100644 --- a/chalk-engine/src/normalize_deep.rs +++ b/chalk-engine/src/normalize_deep.rs @@ -39,7 +39,9 @@ impl<'i, I: Interner> Folder<'i, I> for DeepNormalizer<'_, 'i, I> where I: 'i, { - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I> { + type Error = NoSolution; + + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error> { self } diff --git a/chalk-engine/src/strand.rs b/chalk-engine/src/strand.rs index d2b3d41100e..46445797250 100644 --- a/chalk-engine/src/strand.rs +++ b/chalk-engine/src/strand.rs @@ -5,7 +5,7 @@ use std::fmt::Debug; use chalk_derive::HasInterner; use chalk_ir::fold::{Fold, Folder}; use chalk_ir::interner::Interner; -use chalk_ir::{Canonical, DebruijnIndex, Fallible, UniverseMap}; +use chalk_ir::{Canonical, DebruijnIndex, UniverseMap}; #[derive(Clone, Debug, HasInterner)] pub(crate) struct Strand { @@ -37,11 +37,11 @@ pub(crate) struct SelectedSubgoal { impl Fold for Strand { type Result = Strand; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { diff --git a/chalk-ir/src/fold.rs b/chalk-ir/src/fold.rs index 426164539d9..c8e508681bd 100644 --- a/chalk-ir/src/fold.rs +++ b/chalk-ir/src/fold.rs @@ -58,6 +58,10 @@ pub trait Folder<'i, I: Interner> where I: 'i, { + /// The type this folder returns when folding fails. This is + /// commonly [`NoSolution`]. + type Error; + /// Creates a `dyn` value from this folder. Unfortunately, this /// must be added manually to each impl of Folder; it permits the /// default implements below to create a `&mut dyn Folder` from @@ -65,13 +69,13 @@ where /// method). Effectively, this limits impls of `Folder` to types /// for which we are able to create a dyn value (i.e., not `[T]` /// types). - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I>; + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error>; /// Top-level callback: invoked for each `Ty` that is /// encountered when folding. By default, invokes /// `super_fold_with`, which will in turn invoke the more /// specialized folding methods below, like `fold_free_var_ty`. - fn fold_ty(&mut self, ty: Ty, outer_binder: DebruijnIndex) -> Fallible> { + fn fold_ty(&mut self, ty: Ty, outer_binder: DebruijnIndex) -> Result, Self::Error> { ty.super_fold_with(self.as_dyn(), outer_binder) } @@ -83,7 +87,7 @@ where &mut self, lifetime: Lifetime, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { lifetime.super_fold_with(self.as_dyn(), outer_binder) } @@ -95,7 +99,7 @@ where &mut self, constant: Const, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { constant.super_fold_with(self.as_dyn(), outer_binder) } @@ -104,12 +108,16 @@ where &mut self, clause: ProgramClause, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { clause.super_fold_with(self.as_dyn(), outer_binder) } /// Invoked for every goal. By default, recursively folds the goals contents. - fn fold_goal(&mut self, goal: Goal, outer_binder: DebruijnIndex) -> Fallible> { + fn fold_goal( + &mut self, + goal: Goal, + outer_binder: DebruijnIndex, + ) -> Result, Self::Error> { goal.super_fold_with(self.as_dyn(), outer_binder) } @@ -133,7 +141,7 @@ where &mut self, bound_var: BoundVar, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { if self.forbid_free_vars() { panic!( "unexpected free variable with depth `{:?}` with outer binder {:?}", @@ -150,7 +158,7 @@ where &mut self, bound_var: BoundVar, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { if self.forbid_free_vars() { panic!( "unexpected free variable with depth `{:?}` with outer binder {:?}", @@ -168,7 +176,7 @@ where ty: Ty, bound_var: BoundVar, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { if self.forbid_free_vars() { panic!( "unexpected free variable with depth `{:?}` with outer binder {:?}", @@ -202,7 +210,7 @@ where &mut self, universe: PlaceholderIndex, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { if self.forbid_free_placeholders() { panic!("unexpected placeholder type `{:?}`", universe) } else { @@ -216,7 +224,7 @@ where &mut self, universe: PlaceholderIndex, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { if self.forbid_free_placeholders() { panic!("unexpected placeholder lifetime `{:?}`", universe) } else { @@ -231,7 +239,7 @@ where ty: Ty, universe: PlaceholderIndex, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { if self.forbid_free_placeholders() { panic!("unexpected placeholder const `{:?}`", universe) } else { @@ -259,7 +267,7 @@ where var: InferenceVar, kind: TyVariableKind, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { if self.forbid_inference_vars() { panic!("unexpected inference type `{:?}`", var) } else { @@ -273,7 +281,7 @@ where &mut self, var: InferenceVar, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { if self.forbid_inference_vars() { panic!("unexpected inference lifetime `'{:?}`", var) } else { @@ -288,7 +296,7 @@ where ty: Ty, var: InferenceVar, outer_binder: DebruijnIndex, - ) -> Fallible> { + ) -> Result, Self::Error> { if self.forbid_inference_vars() { panic!("unexpected inference const `{:?}`", var) } else { @@ -318,11 +326,11 @@ pub trait Fold: Debug { /// folder. Typically `binders` starts as 0, but is adjusted when /// we encounter `Binders` in the IR or other similar /// constructs. - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i; } @@ -332,11 +340,11 @@ pub trait Fold: Debug { /// the contents of the type. pub trait SuperFold: Fold { /// Recursively folds the value. - fn super_fold_with<'i>( + fn super_fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i; } @@ -347,11 +355,11 @@ pub trait SuperFold: Fold { impl Fold for Ty { type Result = Ty; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -364,11 +372,11 @@ impl SuperFold for Ty where I: Interner, { - fn super_fold_with<'i>( + fn super_fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible> + ) -> Result, E> where I: 'i, { @@ -477,11 +485,11 @@ where impl Fold for Lifetime { type Result = Lifetime; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -493,11 +501,11 @@ impl SuperFold for Lifetime where I: Interner, { - fn super_fold_with<'i>( + fn super_fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible> + ) -> Result, E> where I: 'i, { @@ -535,11 +543,11 @@ where impl Fold for Const { type Result = Const; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -551,11 +559,11 @@ impl SuperFold for Const where I: Interner, { - fn super_fold_with<'i>( + fn super_fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible> + ) -> Result, E> where I: 'i, { @@ -592,11 +600,11 @@ where impl Fold for Goal { type Result = Goal; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -606,11 +614,11 @@ impl Fold for Goal { /// Superfold folds recursively. impl SuperFold for Goal { - fn super_fold_with<'i>( + fn super_fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -630,11 +638,11 @@ impl SuperFold for Goal { impl Fold for ProgramClause { type Result = ProgramClause; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { diff --git a/chalk-ir/src/fold/binder_impls.rs b/chalk-ir/src/fold/binder_impls.rs index 0c1be6f4b34..641f54a24aa 100644 --- a/chalk-ir/src/fold/binder_impls.rs +++ b/chalk-ir/src/fold/binder_impls.rs @@ -7,11 +7,11 @@ use crate::*; impl Fold for FnPointer { type Result = FnPointer; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -39,11 +39,11 @@ where I: Interner, { type Result = Binders; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -66,11 +66,11 @@ where >::Result: HasInterner, { type Result = Canonical; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { diff --git a/chalk-ir/src/fold/boring_impls.rs b/chalk-ir/src/fold/boring_impls.rs index 7c019216958..77a9027ca34 100644 --- a/chalk-ir/src/fold/boring_impls.rs +++ b/chalk-ir/src/fold/boring_impls.rs @@ -10,11 +10,11 @@ use std::marker::PhantomData; impl, I: Interner> Fold for Vec { type Result = Vec; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -24,11 +24,11 @@ impl, I: Interner> Fold for Vec { impl, I: Interner> Fold for Box { type Result = Box; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -40,7 +40,7 @@ macro_rules! tuple_fold { ($($n:ident),*) => { impl<$($n: Fold,)* I: Interner> Fold for ($($n,)*) { type Result = ($($n::Result,)*); - fn fold_with<'i>(self, folder: &mut dyn Folder<'i, I>, outer_binder: DebruijnIndex) -> Fallible + fn fold_with<'i, Error>(self, folder: &mut dyn Folder<'i, I, Error = Error>, outer_binder: DebruijnIndex) -> Result where I: 'i, { @@ -59,11 +59,11 @@ tuple_fold!(A, B, C, D, E); impl, I: Interner> Fold for Option { type Result = Option; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -76,11 +76,11 @@ impl, I: Interner> Fold for Option { impl Fold for GenericArg { type Result = GenericArg; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -96,11 +96,11 @@ impl Fold for GenericArg { impl Fold for Substitution { type Result = Substitution; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -116,11 +116,11 @@ impl Fold for Substitution { impl Fold for Goals { type Result = Goals; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -135,11 +135,11 @@ impl Fold for Goals { impl Fold for ProgramClauses { type Result = ProgramClauses; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -154,11 +154,11 @@ impl Fold for ProgramClauses { impl Fold for QuantifiedWhereClauses { type Result = QuantifiedWhereClauses; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -173,11 +173,11 @@ impl Fold for QuantifiedWhereClauses { impl Fold for Constraints { type Result = Constraints; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> Fallible + ) -> Result where I: 'i, { @@ -196,11 +196,11 @@ macro_rules! copy_fold { ($t:ty) => { impl $crate::fold::Fold for $t { type Result = Self; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - _folder: &mut dyn ($crate::fold::Folder<'i, I>), + _folder: &mut dyn ($crate::fold::Folder<'i, I, Error = E>), _outer_binder: DebruijnIndex, - ) -> ::chalk_ir::Fallible + ) -> ::std::result::Result where I: 'i, { @@ -231,11 +231,11 @@ macro_rules! id_fold { ($t:ident) => { impl $crate::fold::Fold for $t { type Result = $t; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - _folder: &mut dyn ($crate::fold::Folder<'i, I>), + _folder: &mut dyn ($crate::fold::Folder<'i, I, Error = E>), _outer_binder: DebruijnIndex, - ) -> ::chalk_ir::Fallible + ) -> ::std::result::Result where I: 'i, { @@ -256,11 +256,11 @@ id_fold!(GeneratorId); id_fold!(ForeignDefId); impl SuperFold for ProgramClauseData { - fn super_fold_with<'i>( + fn super_fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> ::chalk_ir::Fallible + ) -> ::std::result::Result where I: 'i, { @@ -269,11 +269,11 @@ impl SuperFold for ProgramClauseData { } impl SuperFold for ProgramClause { - fn super_fold_with<'i>( + fn super_fold_with<'i, E>( self, - folder: &mut dyn Folder<'i, I>, + folder: &mut dyn Folder<'i, I, Error = E>, outer_binder: DebruijnIndex, - ) -> ::chalk_ir::Fallible + ) -> ::std::result::Result where I: 'i, { @@ -287,11 +287,11 @@ impl SuperFold for ProgramClause { impl Fold for PhantomData { type Result = PhantomData; - fn fold_with<'i>( + fn fold_with<'i, E>( self, - _folder: &mut dyn Folder<'i, I>, + _folder: &mut dyn Folder<'i, I, Error = E>, _outer_binder: DebruijnIndex, - ) -> ::chalk_ir::Fallible + ) -> ::std::result::Result where I: 'i, { diff --git a/chalk-ir/src/fold/shift.rs b/chalk-ir/src/fold/shift.rs index 6627bed6db1..fabfb8cf3b5 100644 --- a/chalk-ir/src/fold/shift.rs +++ b/chalk-ir/src/fold/shift.rs @@ -72,7 +72,9 @@ impl Shifter<'_, I> { } impl<'i, I: Interner> Folder<'i, I> for Shifter<'i, I> { - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I> { + type Error = NoSolution; + + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error> { self } @@ -140,7 +142,9 @@ impl DownShifter<'_, I> { } impl<'i, I: Interner> Folder<'i, I> for DownShifter<'i, I> { - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I> { + type Error = NoSolution; + + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error> { self } diff --git a/chalk-ir/src/fold/subst.rs b/chalk-ir/src/fold/subst.rs index baa82dcbd60..0205e99c33b 100644 --- a/chalk-ir/src/fold/subst.rs +++ b/chalk-ir/src/fold/subst.rs @@ -26,7 +26,9 @@ impl Subst<'_, '_, I> { } impl<'i, I: Interner> Folder<'i, I> for Subst<'_, 'i, I> { - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I> { + type Error = NoSolution; + + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error> { self } diff --git a/chalk-ir/src/lib.rs b/chalk-ir/src/lib.rs index 70a29fee9fa..124ae04c3a8 100644 --- a/chalk-ir/src/lib.rs +++ b/chalk-ir/src/lib.rs @@ -2841,7 +2841,9 @@ impl<'a, I: Interner> ToGenericArg for (usize, &'a VariableKind) { } impl<'i, I: Interner, A: AsParameters> Folder<'i, I> for &SubstFolder<'i, I, A> { - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I> { + type Error = NoSolution; + + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error> { self } diff --git a/chalk-solve/src/clauses/generalize.rs b/chalk-solve/src/clauses/generalize.rs index 140ff7855d2..b8b4089fd12 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, Ty, TyKind, TyVariableKind, - VariableKind, VariableKinds, + Binders, BoundVar, DebruijnIndex, Fallible, Lifetime, LifetimeData, NoSolution, Ty, TyKind, + TyVariableKind, VariableKind, VariableKinds, }; use rustc_hash::FxHashMap; @@ -42,7 +42,9 @@ impl Generalize<'_, I> { } impl<'i, I: Interner> Folder<'i, I> for Generalize<'i, I> { - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I> { + type Error = NoSolution; + + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error> { self } diff --git a/chalk-solve/src/infer/canonicalize.rs b/chalk-solve/src/infer/canonicalize.rs index 250c07714df..f87479089b7 100644 --- a/chalk-solve/src/infer/canonicalize.rs +++ b/chalk-solve/src/infer/canonicalize.rs @@ -111,7 +111,9 @@ impl<'i, I: Interner> Folder<'i, I> for Canonicalizer<'i, I> where I: 'i, { - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I> { + type Error = NoSolution; + + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error> { self } diff --git a/chalk-solve/src/infer/invert.rs b/chalk-solve/src/infer/invert.rs index 053cc18c1ce..63980682b1e 100644 --- a/chalk-solve/src/infer/invert.rs +++ b/chalk-solve/src/infer/invert.rs @@ -135,7 +135,9 @@ impl<'i, I: Interner> Folder<'i, I> for Inverter<'i, I> where I: 'i, { - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I> { + type Error = NoSolution; + + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error> { self } diff --git a/chalk-solve/src/infer/ucanonicalize.rs b/chalk-solve/src/infer/ucanonicalize.rs index 2c4958e3f39..a17e59842ec 100644 --- a/chalk-solve/src/infer/ucanonicalize.rs +++ b/chalk-solve/src/infer/ucanonicalize.rs @@ -236,7 +236,9 @@ impl<'i, I: Interner> Folder<'i, I> for UMapToCanonical<'i, I> where I: 'i, { - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I> { + type Error = NoSolution; + + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error> { self } @@ -309,7 +311,9 @@ impl<'i, I: Interner> Folder<'i, I> for UMapFromCanonical<'i, I> where I: 'i, { - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I> { + type Error = NoSolution; + + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error> { self } diff --git a/chalk-solve/src/infer/unify.rs b/chalk-solve/src/infer/unify.rs index 2fd745d1798..2f7d513ac7d 100644 --- a/chalk-solve/src/infer/unify.rs +++ b/chalk-solve/src/infer/unify.rs @@ -1260,7 +1260,9 @@ impl<'i, I: Interner> Folder<'i, I> for OccursCheck<'_, 'i, I> where I: 'i, { - fn as_dyn(&mut self) -> &mut dyn Folder<'i, I> { + type Error = NoSolution; + + fn as_dyn(&mut self) -> &mut dyn Folder<'i, I, Error = Self::Error> { self }