diff --git a/chalk-derive/src/lib.rs b/chalk-derive/src/lib.rs index 53c8e365944..a7d8570c07e 100644 --- a/chalk-derive/src/lib.rs +++ b/chalk-derive/src/lib.rs @@ -175,11 +175,11 @@ fn derive_any_visit( s.bound_impl( quote!(::chalk_ir::visit:: #trait_name <#interner>), quote! { - fn #method_name <'i>( + fn #method_name <'i, B>( &self, - visitor: &mut dyn ::chalk_ir::visit::Visitor < 'i, #interner >, + visitor: &mut dyn ::chalk_ir::visit::Visitor < 'i, #interner, BreakTy = B >, outer_binder: ::chalk_ir::DebruijnIndex, - ) -> ::chalk_ir::visit::ControlFlow<()> + ) -> ::chalk_ir::visit::ControlFlow where #interner: 'i { diff --git a/chalk-ir/src/visit.rs b/chalk-ir/src/visit.rs index 9608c9296ef..77039a65782 100644 --- a/chalk-ir/src/visit.rs +++ b/chalk-ir/src/visit.rs @@ -82,6 +82,9 @@ pub trait Visitor<'i, I: Interner> where I: 'i, { + /// The "break type" of the visitor. + type BreakTy; + /// Creates a `dyn` value from this visitor. Unfortunately, this /// must be added manually to each impl of visitor; it permits the /// default implements below to create a `&mut dyn Visitor` from @@ -89,13 +92,13 @@ where /// method). Effectively, this limits impls of `visitor` to types /// for which we are able to create a dyn value (i.e., not `[T]` /// types). - fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I>; + fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I, BreakTy = Self::BreakTy>; /// Top-level callback: invoked for each `Ty` that is /// encountered when visiting. By default, invokes /// `super_visit_with`, which will in turn invoke the more /// specialized visiting methods below, like `visit_free_var`. - fn visit_ty(&mut self, ty: &Ty, outer_binder: DebruijnIndex) -> ControlFlow<()> { + fn visit_ty(&mut self, ty: &Ty, outer_binder: DebruijnIndex) -> ControlFlow { ty.super_visit_with(self.as_dyn(), outer_binder) } @@ -107,7 +110,7 @@ where &mut self, lifetime: &Lifetime, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> { + ) -> ControlFlow { lifetime.super_visit_with(self.as_dyn(), outer_binder) } @@ -115,7 +118,11 @@ where /// encountered when visiting. By default, invokes /// `super_visit_with`, which will in turn invoke the more /// specialized visiting methods below, like `visit_free_var`. - fn visit_const(&mut self, constant: &Const, outer_binder: DebruijnIndex) -> ControlFlow<()> { + fn visit_const( + &mut self, + constant: &Const, + outer_binder: DebruijnIndex, + ) -> ControlFlow { constant.super_visit_with(self.as_dyn(), outer_binder) } @@ -124,12 +131,16 @@ where &mut self, clause: &ProgramClause, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> { + ) -> ControlFlow { clause.super_visit_with(self.as_dyn(), outer_binder) } /// Invoked for every goal. By default, recursively visits the goals contents. - fn visit_goal(&mut self, goal: &Goal, outer_binder: DebruijnIndex) -> ControlFlow<()> { + fn visit_goal( + &mut self, + goal: &Goal, + outer_binder: DebruijnIndex, + ) -> ControlFlow { goal.super_visit_with(self.as_dyn(), outer_binder) } @@ -138,7 +149,7 @@ where &mut self, domain_goal: &DomainGoal, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> { + ) -> ControlFlow { domain_goal.super_visit_with(self.as_dyn(), outer_binder) } @@ -155,7 +166,7 @@ where &mut self, bound_var: BoundVar, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> { + ) -> ControlFlow { if self.forbid_free_vars() { panic!( "unexpected free variable `{:?}` with outer binder {:?}", @@ -178,7 +189,7 @@ where &mut self, universe: PlaceholderIndex, _outer_binder: DebruijnIndex, - ) -> ControlFlow<()> { + ) -> ControlFlow { if self.forbid_free_placeholders() { panic!("unexpected placeholder type `{:?}`", universe) } else { @@ -191,7 +202,7 @@ where &mut self, where_clause: &WhereClause, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> { + ) -> ControlFlow { where_clause.super_visit_with(self.as_dyn(), outer_binder) } @@ -208,7 +219,7 @@ where &mut self, var: InferenceVar, _outer_binder: DebruijnIndex, - ) -> ControlFlow<()> { + ) -> ControlFlow { if self.forbid_inference_vars() { panic!("unexpected inference type `{:?}`", var) } else { @@ -228,11 +239,11 @@ pub trait Visit: Debug { /// visitor. Typically `binders` starts as 0, but is adjusted when /// we encounter `Binders` in the IR or other similar /// constructs. - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i; } @@ -242,11 +253,11 @@ pub trait Visit: Debug { /// the contents of the type. pub trait SuperVisit: Visit { /// Recursively visits the type contents. - fn super_visit_with<'i>( + fn super_visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i; } @@ -255,11 +266,11 @@ pub trait SuperVisit: Visit { /// usually (in turn) invokes `super_visit_ty` to visit the individual /// parts. impl Visit for Ty { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -272,11 +283,11 @@ impl SuperVisit for Ty where I: Interner, { - fn super_visit_with<'i>( + fn super_visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -346,11 +357,11 @@ where } impl Visit for Lifetime { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -359,11 +370,11 @@ impl Visit for Lifetime { } impl SuperVisit for Lifetime { - fn super_visit_with<'i>( + fn super_visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -387,11 +398,11 @@ impl SuperVisit for Lifetime { } impl Visit for Const { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -400,11 +411,11 @@ impl Visit for Const { } impl SuperVisit for Const { - fn super_visit_with<'i>( + fn super_visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -427,11 +438,11 @@ impl SuperVisit for Const { } impl Visit for Goal { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -440,11 +451,11 @@ impl Visit for Goal { } impl SuperVisit for Goal { - fn super_visit_with<'i>( + fn super_visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -454,11 +465,11 @@ impl SuperVisit for Goal { } impl Visit for ProgramClause { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -467,11 +478,11 @@ impl Visit for ProgramClause { } impl Visit for WhereClause { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -480,11 +491,11 @@ impl Visit for WhereClause { } impl Visit for DomainGoal { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { diff --git a/chalk-ir/src/visit/binder_impls.rs b/chalk-ir/src/visit/binder_impls.rs index 9fc3b0f5f81..2015dca8264 100644 --- a/chalk-ir/src/visit/binder_impls.rs +++ b/chalk-ir/src/visit/binder_impls.rs @@ -7,11 +7,11 @@ use crate::interner::HasInterner; use crate::{Binders, Canonical, ControlFlow, DebruijnIndex, FnPointer, Interner, Visit, Visitor}; impl Visit for FnPointer { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -26,11 +26,11 @@ impl Visit for Binders where T: HasInterner + Visit, { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -43,11 +43,11 @@ where I: Interner, T: HasInterner + Visit, { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { diff --git a/chalk-ir/src/visit/boring_impls.rs b/chalk-ir/src/visit/boring_impls.rs index 2cd6b8b38c7..eef58ddb3ca 100644 --- a/chalk-ir/src/visit/boring_impls.rs +++ b/chalk-ir/src/visit/boring_impls.rs @@ -14,11 +14,11 @@ use crate::{ use std::{marker::PhantomData, sync::Arc}; /// Convenience function to visit all the items in the iterator it. -pub fn visit_iter<'i, T, I>( +pub fn visit_iter<'i, T, I, B>( it: impl Iterator, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, -) -> ControlFlow<()> +) -> ControlFlow where T: Visit, I: 'i + Interner, @@ -30,11 +30,11 @@ where } impl, I: Interner> Visit for &T { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -43,11 +43,11 @@ impl, I: Interner> Visit for &T { } impl, I: Interner> Visit for Vec { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -56,11 +56,11 @@ impl, I: Interner> Visit for Vec { } impl, I: Interner> Visit for &[T] { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -69,11 +69,11 @@ impl, I: Interner> Visit for &[T] { } impl, I: Interner> Visit for Box { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -82,11 +82,11 @@ impl, I: Interner> Visit for Box { } impl, I: Interner> Visit for Arc { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -97,7 +97,7 @@ impl, I: Interner> Visit for Arc { macro_rules! tuple_visit { ($($n:ident),*) => { impl<$($n: Visit,)* I: Interner> Visit for ($($n,)*) { - fn visit_with<'i>(&self, visitor: &mut dyn Visitor<'i, I>, outer_binder: DebruijnIndex) -> ControlFlow<()> where I: 'i + fn visit_with<'i, BT>(&self, visitor: &mut dyn Visitor<'i, I, BreakTy = BT>, outer_binder: DebruijnIndex) -> ControlFlow where I: 'i { #[allow(non_snake_case)] let &($(ref $n),*) = self; @@ -116,11 +116,11 @@ tuple_visit!(A, B, C, D); tuple_visit!(A, B, C, D, E); impl, I: Interner> Visit for Option { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -132,11 +132,11 @@ impl, I: Interner> Visit for Option { } impl Visit for GenericArg { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -146,11 +146,11 @@ impl Visit for GenericArg { } impl Visit for Substitution { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -160,11 +160,11 @@ impl Visit for Substitution { } impl Visit for Goals { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -178,11 +178,11 @@ impl Visit for Goals { macro_rules! const_visit { ($t:ty) => { impl $crate::visit::Visit for $t { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - _visitor: &mut dyn ($crate::visit::Visitor<'i, I>), + _visitor: &mut dyn ($crate::visit::Visitor<'i, I, BreakTy = B>), _outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -212,11 +212,11 @@ const_visit!(Safety); macro_rules! id_visit { ($t:ident) => { impl $crate::visit::Visit for $t { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - _visitor: &mut dyn ($crate::visit::Visitor<'i, I>), + _visitor: &mut dyn ($crate::visit::Visitor<'i, I, BreakTy = B>), _outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -237,11 +237,11 @@ id_visit!(GeneratorId); id_visit!(ForeignDefId); impl SuperVisit for ProgramClause { - fn super_visit_with<'i>( + fn super_visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -252,11 +252,11 @@ impl SuperVisit for ProgramClause { } impl Visit for ProgramClauses { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -267,11 +267,11 @@ impl Visit for ProgramClauses { } impl Visit for Constraints { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -282,11 +282,11 @@ impl Visit for Constraints { } impl Visit for QuantifiedWhereClauses { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn Visitor<'i, I>, + visitor: &mut dyn Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -297,11 +297,11 @@ impl Visit for QuantifiedWhereClauses { } impl Visit for PhantomData { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - _visitor: &mut dyn Visitor<'i, I>, + _visitor: &mut dyn Visitor<'i, I, BreakTy = B>, _outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { diff --git a/chalk-ir/src/visit/visitors.rs b/chalk-ir/src/visit/visitors.rs index 32b68208832..a34514fe725 100644 --- a/chalk-ir/src/visit/visitors.rs +++ b/chalk-ir/src/visit/visitors.rs @@ -21,7 +21,9 @@ struct FindFreeVarsVisitor<'i, I: Interner> { } impl<'i, I: Interner> Visitor<'i, I> for FindFreeVarsVisitor<'i, I> { - fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I> { + type BreakTy = (); + + fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I, BreakTy = Self::BreakTy> { self } diff --git a/chalk-solve/src/clauses/builtin_traits/unsize.rs b/chalk-solve/src/clauses/builtin_traits/unsize.rs index 9962c343d4e..0dcc080a816 100644 --- a/chalk-solve/src/clauses/builtin_traits/unsize.rs +++ b/chalk-solve/src/clauses/builtin_traits/unsize.rs @@ -19,7 +19,9 @@ struct UnsizeParameterCollector<'a, I: Interner> { } impl<'a, I: Interner> Visitor<'a, I> for UnsizeParameterCollector<'a, I> { - fn as_dyn(&mut self) -> &mut dyn Visitor<'a, I> { + type BreakTy = (); + + fn as_dyn(&mut self) -> &mut dyn Visitor<'a, I, BreakTy = Self::BreakTy> { self } @@ -74,7 +76,9 @@ struct ParameterOccurenceCheck<'a, 'p, I: Interner> { } impl<'a, 'p, I: Interner> Visitor<'a, I> for ParameterOccurenceCheck<'a, 'p, I> { - fn as_dyn(&mut self) -> &mut dyn Visitor<'a, I> { + type BreakTy = (); + + fn as_dyn(&mut self) -> &mut dyn Visitor<'a, I, BreakTy = Self::BreakTy> { self } diff --git a/chalk-solve/src/clauses/env_elaborator.rs b/chalk-solve/src/clauses/env_elaborator.rs index c499c9dbc92..de65c106ede 100644 --- a/chalk-solve/src/clauses/env_elaborator.rs +++ b/chalk-solve/src/clauses/env_elaborator.rs @@ -54,7 +54,9 @@ impl<'me, I: Interner> EnvElaborator<'me, I> { } impl<'me, I: Interner> Visitor<'me, I> for EnvElaborator<'me, I> { - fn as_dyn(&mut self) -> &mut dyn Visitor<'me, I> { + type BreakTy = (); + + fn as_dyn(&mut self) -> &mut dyn Visitor<'me, I, BreakTy = Self::BreakTy> { self } diff --git a/chalk-solve/src/infer/ucanonicalize.rs b/chalk-solve/src/infer/ucanonicalize.rs index 67b0af3fd84..9f69d3ec411 100644 --- a/chalk-solve/src/infer/ucanonicalize.rs +++ b/chalk-solve/src/infer/ucanonicalize.rs @@ -205,7 +205,9 @@ impl<'i, I: Interner> Visitor<'i, I> for UCollector<'_, 'i, I> where I: 'i, { - fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I> { + type BreakTy = (); + + fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I, BreakTy = Self::BreakTy> { self } diff --git a/chalk-solve/src/logging_db/id_collector.rs b/chalk-solve/src/logging_db/id_collector.rs index 664a357576b..f0a2aafc364 100644 --- a/chalk-solve/src/logging_db/id_collector.rs +++ b/chalk-solve/src/logging_db/id_collector.rs @@ -108,7 +108,9 @@ impl<'i, I: Interner, DB: RustIrDatabase> Visitor<'i, I> for IdCollector<'i, where I: 'i, { - fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I> { + type BreakTy = (); + + fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I, BreakTy = Self::BreakTy> { self } fn interner(&self) -> &'i I { diff --git a/chalk-solve/src/rust_ir.rs b/chalk-solve/src/rust_ir.rs index 57d65a53422..3491bc1511c 100644 --- a/chalk-solve/src/rust_ir.rs +++ b/chalk-solve/src/rust_ir.rs @@ -142,11 +142,11 @@ pub struct FnDefDatum { /// Avoids visiting `I::FnAbi` impl Visit for FnDefDatum { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn chalk_ir::visit::Visitor<'i, I>, + visitor: &mut dyn chalk_ir::visit::Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { @@ -489,11 +489,11 @@ pub struct AssociatedTyDatum { // Manual implementation to avoid I::Identifier type. impl Visit for AssociatedTyDatum { - fn visit_with<'i>( + fn visit_with<'i, B>( &self, - visitor: &mut dyn chalk_ir::visit::Visitor<'i, I>, + visitor: &mut dyn chalk_ir::visit::Visitor<'i, I, BreakTy = B>, outer_binder: DebruijnIndex, - ) -> ControlFlow<()> + ) -> ControlFlow where I: 'i, { diff --git a/chalk-solve/src/solve/truncate.rs b/chalk-solve/src/solve/truncate.rs index e73bb2ec97e..40a34a69ef3 100644 --- a/chalk-solve/src/solve/truncate.rs +++ b/chalk-solve/src/solve/truncate.rs @@ -39,7 +39,9 @@ impl<'infer, 'i, I: Interner> TySizeVisitor<'infer, 'i, I> { } impl<'infer, 'i, I: Interner> Visitor<'i, I> for TySizeVisitor<'infer, 'i, I> { - fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I> { + type BreakTy = (); + + fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I, BreakTy = Self::BreakTy> { self } diff --git a/chalk-solve/src/wf.rs b/chalk-solve/src/wf.rs index 77b8d001b0c..63f66a8594b 100644 --- a/chalk-solve/src/wf.rs +++ b/chalk-solve/src/wf.rs @@ -69,7 +69,8 @@ impl<'i, I: Interner> InputTypeCollector<'i, I> { } impl<'i, I: Interner> Visitor<'i, I> for InputTypeCollector<'i, I> { - fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I> { + type BreakTy = (); + fn as_dyn(&mut self) -> &mut dyn Visitor<'i, I, BreakTy = Self::BreakTy> { self }