Diffstat (limited to 'src/build/builders/core/struct.rs')
-rw-r--r--src/build/builders/core/struct.rs72
1 files changed, 16 insertions, 56 deletions
diff --git a/src/build/builders/core/struct.rs b/src/build/builders/core/struct.rs
index 6752acb..f874fac 100644
--- a/src/build/builders/core/struct.rs
+++ b/src/build/builders/core/struct.rs
@@ -5,6 +5,7 @@ use effectful::{
effective::Effective,
environment::{DynBind, Environment, NativeForm},
higher_ranked::Mut,
+ SendSync,
tri,
};
@@ -27,6 +28,7 @@ use crate::{
use super::NoopVisitor;
/// A builder for a struct.
+#[derive(SendSync)]
pub struct StructBuilder<'ctx, Info, Mode, E: Environment>
where
Info: StructTypeInfo<'ctx, Mode, E>,
@@ -34,20 +36,7 @@ where
inner: Inner<'ctx, Info, Mode, E>,
}
-unsafe impl<'ctx, Info, Mode, E: Environment> IsSend<E::NeedSend>
- for StructBuilder<'ctx, Info, Mode, E>
-where
- Info: StructTypeInfo<'ctx, Mode, E>,
-{
-}
-
-unsafe impl<'ctx, Info, Mode, E: Environment> IsSync<E::NeedSync>
- for StructBuilder<'ctx, Info, Mode, E>
-where
- Info: StructTypeInfo<'ctx, Mode, E>,
-{
-}
-
+#[derive(SendSync)]
enum Inner<'ctx, Info, Mode, E: Environment>
where
Info: StructTypeInfo<'ctx, Mode, E>,
@@ -65,6 +54,7 @@ where
}
/// Structs are either tuple-like or map-like.
+#[derive(SendSync)]
enum StructKind {
/// A tuple-like struct uses the order of the fields.
Tuple,
@@ -132,6 +122,7 @@ pub trait StructTypeInfo<'ctx, Mode: 'ctx, E: Environment>: 'static {
}
/// Error that [`StructBuilder`] returns.
+#[derive(SendSync)]
pub struct StructError<'ctx, Info, M, E: Environment>
where
Info: StructTypeInfo<'ctx, M, E>,
@@ -140,20 +131,6 @@ where
error: Info::Error,
}
-unsafe impl<'ctx, Info, Mode, E: Environment> IsSend<E::NeedSend>
- for StructError<'ctx, Info, Mode, E>
-where
- Info: StructTypeInfo<'ctx, Mode, E>,
-{
-}
-
-unsafe impl<'ctx, Info, Mode, E: Environment> IsSync<E::NeedSync>
- for StructError<'ctx, Info, Mode, E>
-where
- Info: StructTypeInfo<'ctx, Mode, E>,
-{
-}
-
impl<'ctx, Info, Mode, E: Environment> StructError<'ctx, Info, Mode, E>
where
Info: StructTypeInfo<'ctx, Mode, E>,
@@ -194,6 +171,7 @@ where
impl<'ctx, Info, Mode: 'ctx, E: Environment> StructBuilder<'ctx, Info, Mode, E>
where
+ Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
{
fn make_builders<'e>(&'e mut self) -> NativeForm<'e, (), E>
@@ -220,6 +198,7 @@ where
impl<'ctx, Info, Mode: 'ctx, E: Environment> Builder<'ctx, E> for StructBuilder<'ctx, Info, Mode, E>
where
+ Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
for<'b, 'c> TypeName::T<'b, 'c, Info::ValueT, E>: IsSync<E::NeedSend>,
{
@@ -261,6 +240,7 @@ where
impl<'ctx, Info, Mode: 'ctx, E: Environment> AsVisitor<'ctx, E>
for StructBuilder<'ctx, Info, Mode, E>
where
+ Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
for<'b, 'c> TypeName::T<'b, 'c, Info::ValueT, E>: IsSync<E::NeedSend>,
{
@@ -281,6 +261,7 @@ any_trait! {
SequenceProto<E>
] where
E: Environment,
+ Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
for<'b, 'c> TypeName::T<'b, 'c, Info::ValueT, E>: IsSync<E::NeedSend>,
Mode: 'ctx,
@@ -288,6 +269,7 @@ any_trait! {
impl<'ctx, Info, Mode: 'ctx, E> RequestHint<'ctx, E> for StructBuilder<'ctx, Info, Mode, E>
where
+ Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
for<'b, 'c> TypeName::T<'b, 'c, Info::ValueT, E>: IsSync<E::NeedSend>,
E: Environment,
@@ -353,6 +335,7 @@ where
/// This skips needing to go through each field individually.
impl<'ctx, Info, Mode, E> Value<'ctx, Info::ValueT, E> for StructBuilder<'ctx, Info, Mode, E>
where
+ Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
E: Environment,
for<'a> TypeName::T<'a, 'ctx, Info::ValueT, E>: DynBind<E>,
@@ -378,6 +361,7 @@ where
/// By default [`StructBuilder`] expects a tuple-like struct.
impl<'ctx, Info, Mode: 'ctx, E> Tag<'ctx, tags::Struct, E> for StructBuilder<'ctx, Info, Mode, E>
where
+ Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
E: Environment,
{
@@ -407,6 +391,7 @@ where
/// By default [`StructBuilder`] expects a tuple-like struct.
impl<'ctx, Info, Mode: 'ctx, E> Tag<'ctx, tags::Map, E> for StructBuilder<'ctx, Info, Mode, E>
where
+ Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
E: Environment,
{
@@ -439,6 +424,7 @@ where
/// a sequence of key value pairs. Where the key is the field name.
impl<'ctx, Info, Mode: 'ctx, E> Sequence<'ctx, E> for StructBuilder<'ctx, Info, Mode, E>
where
+ Self: DynBind<E>,
Info: StructTypeInfo<'ctx, Mode, E>,
E: Environment,
{
@@ -522,26 +508,13 @@ where
}
}
+#[derive(SendSync)]
struct FieldVisitor<'a, 'ctx, I: StructTypeInfo<'ctx, M, E>, M, E: Environment> {
builders: &'a mut I::Builders,
marker: Option<I::FieldMarker>,
_marker: Marker<E>,
}
-unsafe impl<'a, 'ctx, Info, Mode, E: Environment> IsSend<E::NeedSend>
- for FieldVisitor<'a, 'ctx, Info, Mode, E>
-where
- Info: StructTypeInfo<'ctx, Mode, E>,
-{
-}
-
-unsafe impl<'a, 'ctx, Info, Mode, E: Environment> IsSync<E::NeedSync>
- for FieldVisitor<'a, 'ctx, Info, Mode, E>
-where
- Info: StructTypeInfo<'ctx, Mode, E>,
-{
-}
-
any_trait! {
impl['ctx, 'a, I, M][E] FieldVisitor<'a, 'ctx, I, M, E> = [
TagProto<tags::Key, E>,
@@ -587,25 +560,12 @@ where
}
}
+#[derive(SendSync)]
struct NameVisitor<'ctx, I: StructTypeInfo<'ctx, M, E>, M, E: Environment> {
field_marker: Option<I::FieldMarker>,
_marker: Marker<E>,
}
-unsafe impl<'ctx, Info, Mode, E: Environment> IsSend<E::NeedSend>
- for NameVisitor<'ctx, Info, Mode, E>
-where
- Info: StructTypeInfo<'ctx, Mode, E>,
-{
-}
-
-unsafe impl<'ctx, Info, Mode, E: Environment> IsSync<E::NeedSync>
- for NameVisitor<'ctx, Info, Mode, E>
-where
- Info: StructTypeInfo<'ctx, Mode, E>,
-{
-}
-
any_trait! {
impl['ctx, I, M][E] NameVisitor<'ctx, I, M, E> = [
ValueProto<OwnedStatic<usize>, E>,