fixed clippy lints
| -rw-r--r-- | src/build/builders/core/struct.rs | 26 | ||||
| -rw-r--r-- | src/effect.rs | 187 | ||||
| -rw-r--r-- | src/effect/blocking.rs | 101 | ||||
| -rw-r--r-- | src/protocol/visitor.rs | 18 | ||||
| -rw-r--r-- | src/protocol/visitor/tag.rs | 5 | ||||
| -rw-r--r-- | src/transform.rs | 1 | ||||
| -rw-r--r-- | tests/builder_struct.rs | 9 | ||||
| -rw-r--r-- | tests/protocol_walker_hint.rs | 15 |
8 files changed, 184 insertions, 178 deletions
diff --git a/src/build/builders/core/struct.rs b/src/build/builders/core/struct.rs index 242f6a4..9ff1862 100644 --- a/src/build/builders/core/struct.rs +++ b/src/build/builders/core/struct.rs @@ -163,7 +163,7 @@ impl<'ctx, Info, Mode: 'ctx, E: Effect> StructBuilder<'ctx, Info, Mode, E> where Info: StructTypeInfo<'ctx, Mode>, { - fn into_builders<'e>(&mut self) -> ErasedEffective<'e, (), E> + fn make_builders<'e>(&mut self) -> ErasedEffective<'e, (), E> where 'ctx: 'e, { @@ -330,13 +330,10 @@ where walker: DynWalkerObjSafe<'walker, 'ctx, E>, ) -> ErasedEffective<'e, VisitResult<DynWalkerObjSafe<'walker, 'ctx, E>>, E> { // If this protocol is used then we need to create the builders. - E::as_ctx(self, |this| this.into_builders().cast()).then(|(this, _)| { - match &mut this.inner { - Inner::Builders { kind, .. } => { - // This signals to go into map mode for the sequence. - *kind = StructKind::Map; - } - _ => {} + E::as_ctx(self, |this| this.make_builders().cast()).then(|(this, _)| { + if let Inner::Builders { kind, .. } = &mut this.inner { + // This signals to go into map mode for the sequence. + *kind = StructKind::Map; } // Walk the walker so nothing complains. @@ -359,13 +356,10 @@ where walker: DynWalkerObjSafe<'walker, 'ctx, E>, ) -> ErasedEffective<'e, VisitResult<DynWalkerObjSafe<'walker, 'ctx, E>>, E> { // If this protocol is used then we need to create the builders. - E::as_ctx(self, |this| this.into_builders().cast()).then(|(this, _)| { - match &mut this.inner { - Inner::Builders { kind, .. } => { - // This signals to go into map mode for the sequence. - *kind = StructKind::Map; - } - _ => {} + E::as_ctx(self, |this| this.make_builders().cast()).then(|(this, _)| { + if let Inner::Builders { kind, .. } = &mut this.inner { + // This signals to go into map mode for the sequence. + *kind = StructKind::Map; } // Walk the walker so nothing complains. @@ -393,7 +387,7 @@ where 'ctx: 'a + 'b + 'c, { // If this protocol is used then we need to create the builders. - E::as_ctx(self, |this| this.into_builders().cast()) + E::as_ctx(self, |this| this.make_builders().cast()) .as_ctx(|(this, _)| { match &mut this.inner { // We should treat the sequence as just values. diff --git a/src/effect.rs b/src/effect.rs index 14c13c2..50dab50 100644 --- a/src/effect.rs +++ b/src/effect.rs @@ -100,9 +100,9 @@ pub trait Effect: Join<Effect = Self> + TryJoin<Effect = Self> + Ss + Sized + 's fn ready<'a, T: Ss + 'a>(value: T) -> ErasedEffective<'a, T, Self>; - fn from_future<'a, F: Ss + 'a>(future: F) -> ErasedEffective<'a, F::Output, Self> + fn from_future<'a, F>(future: F) -> ErasedEffective<'a, F::Output, Self> where - F: Future, + F: Ss + 'a + Future, F::Output: Ss + 'a; } @@ -215,35 +215,35 @@ macro_rules! tri { pub use tri; pub trait EffectExt: Effect { - fn repeat_map<'ctx, 'wrap, I: Ss + 'wrap, U: Ss, F: Ss>( - input: I, - f: F, - ) -> ErasedEffective<'wrap, U, Self> + fn repeat_map<'ctx, 'wrap, I, U, F>(input: I, f: F) -> ErasedEffective<'wrap, U, Self> where F: for<'temp> FnMut(&'temp mut I) -> ErasedEffective<'temp, ControlFlow<U>, Self, &'ctx ()>, + I: Ss + 'wrap, + U: Ss, + F: Ss, 'ctx: 'wrap, { Self::ready(input).repeat_map(f) } #[inline(always)] - fn as_ctx<'ctx, 'wrap, I: Ss + 'wrap, U: Ss, F: Ss>( - input: I, - f: F, - ) -> ErasedEffective<'wrap, (I, U), Self> + fn as_ctx<'ctx, 'wrap, I, U, F>(input: I, f: F) -> ErasedEffective<'wrap, (I, U), Self> where F: for<'temp> FnOnce(&'temp mut I) -> ErasedEffective<'temp, U, Self, &'ctx ()>, + I: Ss + 'wrap, + U: Ss, + F: Ss, 'ctx: 'wrap, { Self::ready(input).as_ctx(f) } - fn as_ctx_map<'ctx, 'wrap, I: Ss + 'wrap, U: Ss, F: Ss>( - input: I, - f: F, - ) -> ErasedEffective<'wrap, U, Self> + fn as_ctx_map<'ctx, 'wrap, I, U, F>(input: I, f: F) -> ErasedEffective<'wrap, U, Self> where F: for<'temp> FnOnce(&'temp mut I) -> ErasedEffective<'temp, U, Self, &'ctx ()>, + I: Ss + 'wrap, + U: Ss, + F: Ss, 'ctx: 'wrap, { Self::ready(input).as_ctx_map(f) @@ -269,9 +269,11 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { self.map(|(ctx, _)| ctx) } - fn map<'wrap, U: Ss, F: Ss>(self, f: F) -> ErasedEffective<'wrap, U, Self::Effect> + fn map<'wrap, U, F>(self, f: F) -> ErasedEffective<'wrap, U, Self::Effect> where F: FnOnce(Self::Output) -> U, + U: Ss, + F: Ss, 'lt: 'wrap, { self.r#do( @@ -284,9 +286,11 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { ) } - fn then<'wrap, U: Ss, F: Ss>(self, f: F) -> ErasedEffective<'wrap, U, Self::Effect> + fn then<'wrap, U, F>(self, f: F) -> ErasedEffective<'wrap, U, Self::Effect> where F: FnOnce(Self::Output) -> ErasedEffective<'wrap, U, Self::Effect>, + U: Ss, + F: Ss, 'lt: 'wrap, { self.r#do( @@ -299,10 +303,12 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { ) } - fn or_else<'wrap, U: Ss, F: Ss>(self, f: F) -> ErasedEffective<'wrap, Option<U>, Self::Effect> + fn or_else<'wrap, U, F>(self, f: F) -> ErasedEffective<'wrap, Option<U>, Self::Effect> where Self: Effective<'lt, Output = Option<U>>, F: FnOnce() -> ErasedEffective<'wrap, Option<U>, Self::Effect>, + U: Ss, + F: Ss, 'lt: 'wrap, { self.r#do( @@ -323,8 +329,9 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { ) } + #[allow(clippy::wrong_self_convention)] #[inline(always)] - fn as_ctx<'ctx: 'lt, 'wrap, U: Ss, F: Ss>( + fn as_ctx<'ctx, 'wrap, U, F>( self, f: F, ) -> ErasedEffective<'wrap, (Self::Output, U), Self::Effect> @@ -332,6 +339,9 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { F: for<'temp> FnOnce( &'temp mut Self::Output, ) -> ErasedEffective<'temp, U, Self::Effect, &'ctx ()>, + U: Ss, + F: Ss, + 'ctx: 'lt, 'lt: 'wrap, { self.r#do( @@ -345,14 +355,15 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { ) } - fn as_ctx_map<'ctx: 'lt, 'wrap, U: Ss, F: Ss>( - self, - f: F, - ) -> ErasedEffective<'wrap, U, Self::Effect> + #[allow(clippy::wrong_self_convention)] + fn as_ctx_map<'ctx, 'wrap, U, F>(self, f: F) -> ErasedEffective<'wrap, U, Self::Effect> where F: for<'temp> FnOnce( &'temp mut Self::Output, ) -> ErasedEffective<'temp, U, Self::Effect, &'ctx ()>, + 'ctx: 'lt, + U: Ss, + F: Ss, 'lt: 'wrap, { self.r#do( @@ -365,7 +376,8 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { ) } - fn as_ctx_or_else<'ctx: 'lt, 'wrap, Ctx: Ss, U: Ss, F: Ss>( + #[allow(clippy::wrong_self_convention)] + fn as_ctx_or_else<'ctx, 'wrap, Ctx, U, F>( self, f: F, ) -> ErasedEffective<'wrap, (Ctx, Option<U>), Self::Effect> @@ -374,6 +386,10 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { F: for<'temp> FnOnce( &'temp mut Ctx, ) -> ErasedEffective<'temp, Option<U>, Self::Effect, &'ctx ()>, + 'ctx: 'lt, + Ctx: Ss, + U: Ss, + F: Ss, 'lt: 'wrap, { self.r#do( @@ -394,7 +410,8 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { ) } - fn as_ctx_or_else_map<'ctx: 'lt, 'wrap, Ctx: Ss, U: Ss, F: Ss>( + #[allow(clippy::wrong_self_convention)] + fn as_ctx_or_else_map<'ctx, 'wrap, Ctx, U, F>( self, f: F, ) -> ErasedEffective<'wrap, Option<U>, Self::Effect> @@ -403,6 +420,10 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { F: for<'temp> FnOnce( &'temp mut Ctx, ) -> ErasedEffective<'temp, Option<U>, Self::Effect, &'ctx ()>, + 'ctx: 'lt, + Ctx: Ss, + U: Ss, + F: Ss, 'lt: 'wrap, { self.r#do( @@ -423,7 +444,7 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { ) } - fn repeat<'ctx: 'lt, 'wrap, U: Ss, F: Ss>( + fn repeat<'ctx, 'wrap, U, F>( self, mut f: F, ) -> ErasedEffective<'wrap, (Self::Output, U), Self::Effect> @@ -432,6 +453,9 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { &'temp mut Self::Output, ) -> ErasedEffective<'temp, ControlFlow<U>, Self::Effect, &'ctx ()>, + 'ctx: 'lt, + U: Ss, + F: Ss, 'lt: 'wrap, { self.r#do( @@ -444,15 +468,15 @@ pub trait EffectiveExt<'lt>: Effective<'lt> { ) } - fn repeat_map<'ctx: 'lt, 'wrap, U: Ss, F: Ss>( - self, - mut f: F, - ) -> ErasedEffective<'wrap, U, Self::Effect> + fn repeat_map<'ctx, 'wrap, U, F>(self, mut f: F) -> ErasedEffective<'wrap, U, Self::Effect> where F: for<'temp> FnMut( &'temp mut Self::Output, ) -> ErasedEffective<'temp, ControlFlow<U>, Self::Effect, &'ctx ()>, + 'ctx: 'lt, + U: Ss, + F: Ss, 'lt: 'wrap, { self.r#do( @@ -490,19 +514,19 @@ pub trait Effective<'lt>: Sized + Ss + 'lt { fn r#do< 'ctx: 'lt, 'wrap, - Pre: Ss, - Ctx: Ss, - Owned: Ss, - First: Ss, - FirstOutput: Ss, - FirstPost: Ss, - Done: Ss, - Extra: Ss, - Repeat: Ss, - RepeatOutput: Ss, - RepeatPost: Ss, - Post: Ss, - Return: Ss, + Pre, + Ctx, + Owned, + First, + FirstOutput, + FirstPost, + Done, + Extra, + Repeat, + RepeatOutput, + RepeatPost, + Post, + Return, >( self, pre: Pre, @@ -513,21 +537,26 @@ pub trait Effective<'lt>: Sized + Ss + 'lt { post: Post, ) -> ErasedEffective<'wrap, Return, Self::Effect> where - Pre: FnOnce(Self::Output) -> (Ctx, ControlFlow<Done, Owned>), - First: for<'temp> FnOnce( - &'temp mut Ctx, - Owned, - ) - -> ErasedEffective<'temp, FirstOutput, Self::Effect, &'wrap ()>, - FirstPost: for<'temp> FnOnce(&'temp mut Ctx, FirstOutput) -> ControlFlow<Done, Extra>, - Repeat: for<'temp> FnMut( - &'temp mut Ctx, - &'temp mut Extra, - ) - -> ErasedEffective<'temp, RepeatOutput, Self::Effect, &'wrap ()>, - RepeatPost: - for<'temp> FnMut(&'temp mut Ctx, &'temp mut Extra, RepeatOutput) -> ControlFlow<Done>, - Post: FnOnce(Ctx, Option<Extra>, Done) -> Return, + Pre: Ss + FnOnce(Self::Output) -> (Ctx, ControlFlow<Done, Owned>), + First: Ss + + for<'temp> FnOnce( + &'temp mut Ctx, + Owned, + ) + -> ErasedEffective<'temp, FirstOutput, Self::Effect, &'wrap ()>, + FirstPost: Ss + for<'temp> FnOnce(&'temp mut Ctx, FirstOutput) -> ControlFlow<Done, Extra>, + Repeat: Ss + + for<'temp> FnMut( + &'temp mut Ctx, + &'temp mut Extra, + ) + -> ErasedEffective<'temp, RepeatOutput, Self::Effect, &'wrap ()>, + RepeatPost: Ss + + for<'temp> FnMut(&'temp mut Ctx, &'temp mut Extra, RepeatOutput) -> ControlFlow<Done>, + Post: Ss + FnOnce(Ctx, Option<Extra>, Done) -> Return, + Return: Ss, + RepeatOutput: Ss, + FirstOutput: Ss, 'lt: 'wrap; } @@ -569,18 +598,16 @@ pub trait Join { T1: Effective<'a, Effect = Self::Effect>, T2: Effective<'a, Effect = Self::Effect>; - fn two<'a, T0: Ss + 'a, T1: Ss + 'a>(effectives: (T0, T1)) -> Self::Two<'a, T0, T1> + fn two<'a, T0, T1>(effectives: (T0, T1)) -> Self::Two<'a, T0, T1> where - T0: Effective<'a, Effect = Self::Effect>, - T1: Effective<'a, Effect = Self::Effect>; + T0: Ss + 'a + Effective<'a, Effect = Self::Effect>, + T1: Ss + 'a + Effective<'a, Effect = Self::Effect>; - fn three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a>( - effectives: (T0, T1, T2), - ) -> Self::Three<'a, T0, T1, T2> + fn three<'a, T0, T1, T2>(effectives: (T0, T1, T2)) -> Self::Three<'a, T0, T1, T2> where - T0: Effective<'a, Effect = Self::Effect>, - T1: Effective<'a, Effect = Self::Effect>, - T2: Effective<'a, Effect = Self::Effect>; + T0: Ss + 'a + Effective<'a, Effect = Self::Effect>, + T1: Ss + 'a + Effective<'a, Effect = Self::Effect>, + T2: Ss + 'a + Effective<'a, Effect = Self::Effect>; } pub trait TryJoin { @@ -605,25 +632,21 @@ pub trait TryJoin { T1: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, T2: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>; - fn two<'a, T0: Ss + 'a, T1: Ss + 'a, F0: Ss + 'a, F1: Ss + 'a>( - cb: (F0, F1), - ) -> Self::Two<'a, T0, T1> + fn two<'a, T0, T1, F0, F1>(cb: (F0, F1)) -> Self::Two<'a, T0, T1> where - T0: TryEffective<'a, Effect = Self::Effect>, - T1: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, - F0: FnOnce() -> T0, - F1: FnOnce() -> T1; + T0: Ss + 'a + TryEffective<'a, Effect = Self::Effect>, + T1: Ss + 'a + TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, + F0: Ss + 'a + FnOnce() -> T0, + F1: Ss + 'a + FnOnce() -> T1; - fn three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a, F0: Ss + 'a, F1: Ss + 'a, F2: Ss + 'a>( - cb: (F0, F1, F2), - ) -> Self::Three<'a, T0, T1, T2> + fn three<'a, T0, T1, T2, F0, F1, F2>(cb: (F0, F1, F2)) -> Self::Three<'a, T0, T1, T2> where - T0: TryEffective<'a, Effect = Self::Effect>, - T1: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, - T2: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, - F0: FnOnce() -> T0, - F1: FnOnce() -> T1, - F2: FnOnce() -> T2; + T0: Ss + 'a + TryEffective<'a, Effect = Self::Effect>, + T1: Ss + 'a + TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, + T2: Ss + 'a + TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, + F0: Ss + 'a + FnOnce() -> T0, + F1: Ss + 'a + FnOnce() -> T1, + F2: Ss + 'a + FnOnce() -> T2; } pub fn join<'lt, E: Effect, T: Joinable<'lt, E>>(x: T) -> T::Output { diff --git a/src/effect/blocking.rs b/src/effect/blocking.rs index b95e643..1400c9d 100644 --- a/src/effect/blocking.rs +++ b/src/effect/blocking.rs @@ -67,19 +67,19 @@ impl<'lt, U: Ss + 'lt, B: BlockOn> Effective<'lt> for Value<U, B> { fn r#do< 'ctx: 'lt, 'wrap, - Pre: Ss, - Ctx: Ss, - Owned: Ss, - First: Ss, - FirstOutput: Ss, - FirstPost: Ss, - Done: Ss, - Extra: Ss, - Repeat: Ss, - RepeatOutput: Ss, - RepeatPost: Ss, - Post: Ss, - Return: Ss, + Pre, + Ctx, + Owned, + First, + FirstOutput, + FirstPost, + Done, + Extra, + Repeat, + RepeatOutput, + RepeatPost, + Post, + Return, >( self, pre: Pre, @@ -90,19 +90,24 @@ impl<'lt, U: Ss + 'lt, B: BlockOn> Effective<'lt> for Value<U, B> { post: Post, ) -> ErasedEffective<'wrap, Return, Self::Effect> where - Pre: FnOnce(Self::Output) -> (Ctx, ControlFlow<Done, Owned>), - First: for<'b> FnOnce( - &'b mut Ctx, - Owned, - ) -> ErasedEffective<'b, FirstOutput, Self::Effect, &'wrap ()>, - FirstPost: for<'b> FnOnce(&'b mut Ctx, FirstOutput) -> ControlFlow<Done, Extra>, - Repeat: for<'b> FnMut( - &'b mut Ctx, - &'b mut Extra, - ) - -> ErasedEffective<'b, RepeatOutput, Self::Effect, &'wrap ()>, - RepeatPost: for<'b> FnMut(&'b mut Ctx, &'b mut Extra, RepeatOutput) -> ControlFlow<Done>, - Post: FnOnce(Ctx, Option<Extra>, Done) -> Return, + Pre: Ss + FnOnce(Self::Output) -> (Ctx, ControlFlow<Done, Owned>), + First: Ss + + for<'b> FnOnce( + &'b mut Ctx, + Owned, + ) -> ErasedEffective<'b, FirstOutput, Self::Effect, &'wrap ()>, + FirstPost: Ss + for<'b> FnOnce(&'b mut Ctx, FirstOutput) -> ControlFlow<Done, Extra>, + Repeat: Ss + + for<'b> FnMut( + &'b mut Ctx, + &'b mut Extra, + ) -> ErasedEffective<'b, RepeatOutput, Self::Effect, &'wrap ()>, + RepeatPost: + Ss + for<'b> FnMut(&'b mut Ctx, &'b mut Extra, RepeatOutput) -> ControlFlow<Done>, + Post: Ss + FnOnce(Ctx, Option<Extra>, Done) -> Return, + Return: Ss, + FirstOutput: Ss, + RepeatOutput: Ss, 'lt: 'wrap, { let (ctx, done, extra) = match pre(self.0) { @@ -148,10 +153,10 @@ impl<B: BlockOn> Join for Blocking<B> { T1: Effective<'a, Effect = Self::Effect>, T2: Effective<'a, Effect = Self::Effect>; - fn two<'a, T0: Ss + 'a, T1: Ss + 'a>(cb: (T0, T1)) -> Self::Two<'a, T0, T1> + fn two<'a, T0, T1>(cb: (T0, T1)) -> Self::Two<'a, T0, T1> where - T0: Effective<'a, Effect = Self::Effect>, - T1: Effective<'a, Effect = Self::Effect>, + T0: Ss + 'a + Effective<'a, Effect = Self::Effect>, + T1: Ss + 'a + Effective<'a, Effect = Self::Effect>, { let v0 = cb.0.cast::<()>().0; let v1 = cb.1.cast::<()>().0; @@ -159,13 +164,11 @@ impl<B: BlockOn> Join for Blocking<B> { Value((v0, v1), Default::default()) } - fn three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a>( - cb: (T0, T1, T2), - ) -> Self::Three<'a, T0, T1, T2> + fn three<'a, T0, T1, T2>(cb: (T0, T1, T2)) -> Self::Three<'a, T0, T1, T2> where - T0: Effective<'a, Effect = Self::Effect>, - T1: Effective<'a, Effect = Self::Effect>, - T2: Effective<'a, Effect = Self::Effect>, + T0: Ss + 'a + Effective<'a, Effect = Self::Effect>, + T1: Ss + 'a + Effective<'a, Effect = Self::Effect>, + T2: Ss + 'a + Effective<'a, Effect = Self::Effect>, { let v0 = cb.0.cast::<()>().0; let v1 = cb.1.cast::<()>().0; @@ -189,14 +192,12 @@ impl<B: BlockOn> TryJoin for Blocking<B> { T1: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, T2: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>; - fn two<'a, T0: Ss + 'a, T1: Ss + 'a, F0: Ss + 'a, F1: Ss + 'a>( - cb: (F0, F1), - ) -> Self::Two<'a, T0, T1> + fn two<'a, T0, T1, F0, F1>(cb: (F0, F1)) -> Self::Two<'a, T0, T1> where - T0: TryEffective<'a, Effect = Self::Effect>, - T1: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, - F0: FnOnce() -> T0, - F1: FnOnce() -> T1, + T0: Ss + 'a + TryEffective<'a, Effect = Self::Effect>, + T1: Ss + 'a + TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, + F0: Ss + 'a + FnOnce() -> T0, + F1: Ss + 'a + FnOnce() -> T1, { let v0 = match (cb.0)().cast::<()>().0 { Ok(v) => v, @@ -211,16 +212,14 @@ impl<B: BlockOn> TryJoin for Blocking<B> { Value(Ok((v0, v1)), Default::default()) } - fn three<'a, T0: Ss + 'a, T1: Ss + 'a, T2: Ss + 'a, F0: Ss + 'a, F1: Ss + 'a, F2: Ss + 'a>( - cb: (F0, F1, F2), - ) -> Self::Three<'a, T0, T1, T2> + fn three<'a, T0, T1, T2, F0, F1, F2>(cb: (F0, F1, F2)) -> Self::Three<'a, T0, T1, T2> where - T0: TryEffective<'a, Effect = Self::Effect>, - T1: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, - T2: TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, - F0: FnOnce() -> T0, - F1: FnOnce() -> T1, - F2: FnOnce() -> T2, + T0: Ss + 'a + TryEffective<'a, Effect = Self::Effect>, + T1: Ss + 'a + TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, + T2: Ss + 'a + TryEffective<'a, Err = T0::Err, Effect = Self::Effect>, + F0: Ss + 'a + FnOnce() -> T0, + F1: Ss + 'a + FnOnce() -> T1, + F2: Ss + 'a + FnOnce() -> T2, { let v0 = match (cb.0)().cast::<()>().0 { Ok(v) => v, diff --git a/src/protocol/visitor.rs b/src/protocol/visitor.rs index 35f24ea..aac873f 100644 --- a/src/protocol/visitor.rs +++ b/src/protocol/visitor.rs @@ -82,16 +82,19 @@ impl<S> VisitResult<S> { } pub trait EffectiveVisitExt<'lt>: Effective<'lt> { - fn if_skipped<'ctx: 'lt, 'wrap, Ctx: Ss, F: Ss>( + fn if_skipped<'ctx, 'wrap, Ctx, F>( self, f: F, ) -> ErasedEffective<'wrap, (Ctx, VisitResult<()>), Self::Effect> where Self: Effective<'lt, Output = (Ctx, VisitResult<()>)>, - F: for<'temp> FnOnce( - &'temp mut Ctx, - ) - -> ErasedEffective<'temp, VisitResult<()>, Self::Effect, &'ctx ()>, + F: Ss + + for<'temp> FnOnce( + &'temp mut Ctx, + ) + -> ErasedEffective<'temp, VisitResult<()>, Self::Effect, &'ctx ()>, + Ctx: Ss, + 'ctx: 'lt, 'lt: 'wrap, { self.r#do( @@ -112,7 +115,7 @@ pub trait EffectiveVisitExt<'lt>: Effective<'lt> { ) } - fn if_not_finished<'ctx: 'lt, 'wrap, Ctx: Ss, F: Ss>( + fn if_not_finished<'ctx, 'wrap, Ctx, F>( self, f: F, ) -> ErasedEffective<'wrap, (Ctx, VisitResult<()>), Self::Effect> @@ -122,6 +125,9 @@ pub trait EffectiveVisitExt<'lt>: Effective<'lt> { &'temp mut Ctx, ) -> ErasedEffective<'temp, VisitResult<()>, Self::Effect, &'ctx ()>, + 'ctx: 'lt, + Ctx: Ss, + F: Ss, 'lt: 'wrap, { self.r#do( diff --git a/src/protocol/visitor/tag.rs b/src/protocol/visitor/tag.rs index 030cc56..9f71868 100644 --- a/src/protocol/visitor/tag.rs +++ b/src/protocol/visitor/tag.rs @@ -168,10 +168,7 @@ pub fn visit_tag< kind: K, visitor: DynVisitor<'visitor, 'ctx>, walker: W, -) -> ErasedEffective<'wrap, Result<VisitResult<W>, TagError<W::Error>>, E> -where - W: WalkerTypes, -{ +) -> ErasedEffective<'wrap, Result<VisitResult<W>, TagError<W::Error>>, E> { // Wrap the walker to allow it to be passed to a dyn walker argument. let walker = DynWalkerAdapter::new(walker); diff --git a/src/transform.rs b/src/transform.rs index 6c4369e..f055fcb 100644 --- a/src/transform.rs +++ b/src/transform.rs @@ -91,6 +91,7 @@ pub trait WalkExt { Walk::into_walker(self) } + #[allow(clippy::result_unit_err)] fn walk<'ctx: 'a, 'a, B>(&'a self, builder: B) -> Result<B::Value, ()> where &'a Self: Walk<'ctx, DefaultMode, Blocking>, diff --git a/tests/builder_struct.rs b/tests/builder_struct.rs index f9400c5..8dc9949 100644 --- a/tests/builder_struct.rs +++ b/tests/builder_struct.rs @@ -2,16 +2,13 @@ use macro_rules_attribute::derive; use treaty::{ any::{OwnedStatic, TempBorrowedStatic}, effect::blocking::Blocking, - protocol::visitor::{tags, visit_sequence, visit_tag, visit_value, TagConst, VisitResult}, + protocol::visitor::{tags, visit_sequence, visit_tag, TagConst, VisitResult}, walkers::core::noop::NoopWalker, - Build, BuildExt as _, Builder, DefaultMode, Flow, + Build, BuildExt as _, Builder, Flow, }; use crate::common::{ - protocol::{ - sequence::MockSequenceScope, - value::{MockValueVisitor, ValueVisitorExt as _}, - }, + protocol::{sequence::MockSequenceScope, value::ValueVisitorExt as _}, walker::MockWalker, }; diff --git a/tests/protocol_walker_hint.rs b/tests/protocol_walker_hint.rs index 53f96da..5c75f33 100644 --- a/tests/protocol_walker_hint.rs +++ b/tests/protocol_walker_hint.rs @@ -1,22 +1,11 @@ use std::any::TypeId; -use common::protocol::hint::MockHintWalker; use treaty::{ any::TypeNameId, - effect::{ - blocking::{Blocking, Spin}, - Effect, Effective, ErasedEffective, - }, - hkt::higher_ranked_type, - protocol::{ - walker::hint::{self, Hint, HintMeta, HintProto, Meta, MetaHint, MetaKnown}, - DynVisitor, - }, - Flow, + effect::blocking::Blocking, + protocol::walker::hint::{self, HintMeta, HintProto}, }; -use crate::common::{builder::MockBuilder, protocol::hint::KnownFactory}; - mod common; // /// This tests for the hint protocol being able to give the known info and being able to hint. |