Diffstat (limited to 'tests/common/protocol/hint.rs')
-rw-r--r--tests/common/protocol/hint.rs64
1 files changed, 36 insertions, 28 deletions
diff --git a/tests/common/protocol/hint.rs b/tests/common/protocol/hint.rs
index 93a5a2d..ed796ba 100644
--- a/tests/common/protocol/hint.rs
+++ b/tests/common/protocol/hint.rs
@@ -1,13 +1,14 @@
use effectful::{
- bound::{Bool, IsSend, IsSync},
- effective::{Effective, Canonical},
- environment::{Environment},
+ bound::{Bool, DynBind, IsSend, IsSync, No, SsBound},
+ effective::{Canonical, Effective},
+ environment::Environment,
forward_send_sync,
higher_ranked::WithLt,
+ is_not_send_sync,
};
use mockall::mock;
use treaty::{
- any::{type_name, AnyTrait, MutAnyUnsized, WithLtTypeId, trait_by_id},
+ any::{trait_by_id, type_name, AnyTrait, MutAnyUnsized, WithLtTypeId},
protocol::{
visitor::VisitResult,
walker::hint::{DynVisitorWith, Hint, HintMeta},
@@ -22,23 +23,31 @@ pub type KnownFactory<P> = for<'a, 'ctx> fn(
) -> Result<WithLt<'a, <P as HintMeta>::Known>, ()>;
mock! {
- pub HintWalker<P: ?Sized + HintMeta> {
- pub fn hint<'a, 'b, 'c, 'lt, 'ctx>(&'a mut self, visitor: DynVisitorWith<'b, 'lt, 'ctx, P>, hint: WithLt<'c, P::Hint>) -> VisitResult;
+ pub HintWalker<P: ?Sized + HintMeta>
+ where
+ for<'r> WithLt<'r, P::Hint>: Sized
+ {
+ pub fn hint<'r, 'src>(&'r mut self, visitor: DynVisitorWith<'r, 'src, P>, hint: WithLt<'r, P::Hint>) -> VisitResult;
pub fn known(&self) -> KnownFactory<P>;
}
}
-forward_send_sync!({} {} {P: (?Sized + HintMeta + Send)} MockHintWalker<P>);
+is_not_send_sync! {
+ {P: (?Sized + HintMeta)} MockHintWalker<P>
+ where {
+ for<'r> WithLt<'r, P::Hint>: Sized
+ },
+}
-impl<'lt, 'ctx: 'lt, P: ?Sized + HintMeta + Send> AnyTrait<'lt, 'ctx> for MockHintWalker<P> {
- fn upcast_by_id_mut<'a>(
- &'a mut self,
- id: WithLtTypeId<'lt, 'ctx>,
- ) -> Option<MutAnyUnsized<'a, 'lt, 'ctx>>
- where
- 'lt: 'a,
- {
+impl<'src, P: ?Sized + HintMeta> AnyTrait<'src> for MockHintWalker<P>
+where
+ P::Env: SsBound<NeedSend = No, NeedSync = No>,
+ Self: Hint<'src, P>,
+ for<'r> WithLt<'r, P::Hint>: Sized,
+ for<'r> WithLt<'r, P::Known>: Sized + DynBind<P::Env>,
+{
+ fn upcast_by_id_mut(&mut self, id: WithLtTypeId<'src>) -> Option<MutAnyUnsized<'_, 'src>> {
trait_by_id!(&mut self, id, {
type Impls = (dyn Hint<P>);
});
@@ -55,25 +64,24 @@ impl<'lt, 'ctx: 'lt, P: ?Sized + HintMeta + Send> AnyTrait<'lt, 'ctx> for MockHi
// P: HintMeta<Effect = E>,
// }
-impl<'ctx, P: ?Sized + HintMeta + Send> Hint<'ctx, P> for MockHintWalker<P> {
- fn hint<'this: 'e, 'visitor: 'e, 'lt: 'e, 'hint: 'e, 'e>(
- &'this mut self,
- visitor: DynVisitorWith<'visitor, 'lt, 'ctx, P>,
- hint: WithLt<'hint, <P as HintMeta>::Hint>,
- ) -> Canonical<'e, VisitResult, <P>::Env>
- where
- 'ctx: 'this + 'visitor + 'hint,
- {
+impl<'ctx, P: ?Sized + HintMeta> Hint<'ctx, P> for MockHintWalker<P>
+where
+ P::Env: SsBound<NeedSend = No, NeedSync = No>,
+ for<'r> WithLt<'r, P::Hint>: Sized,
+ for<'r> WithLt<'r, P::Known>: Sized + DynBind<P::Env>,
+{
+ fn hint<'r>(
+ &'r mut self,
+ visitor: DynVisitorWith<'r, 'ctx, P>,
+ hint: WithLt<'r, <P as HintMeta>::Hint>,
+ ) -> Canonical<'r, VisitResult, <P>::Env> {
P::Env::value(self.hint(visitor, hint)).cast()
}
fn known<'a>(
&'a mut self,
hint: &'a WithLt<'a, <P as HintMeta>::Hint>,
- ) -> Canonical<'a, Result<WithLt<'a, <P as HintMeta>::Known>, ()>, <P>::Env>
- where
- WithLt<'a, <P as HintMeta>::Known>: effectful::bound::DynBind<<P>::Env>,
- {
+ ) -> Canonical<'a, Result<WithLt<'a, <P as HintMeta>::Known>, ()>, <P>::Env> {
todo!()
}