reformat messy code that rustfmt doesn't format

This commit is contained in:
Jacob Lifshay 2024-07-10 23:34:41 -07:00
parent 929e9f8b16
commit 8bd7fcfa27
Signed by: programmerjake
SSH key fingerprint: SHA256:B1iRVvUJkvd7upMIiMqn6OyxvD2SgJkAH3ZnUOj6z+c
14 changed files with 647 additions and 196 deletions

View file

@ -85,7 +85,8 @@ macro_rules! impl_fold {
$($field:ident: $field_ty:ty,)*
}
) => {
impl<State: ?Sized + syn::fold::Fold, $($T,)*> $crate::fold::DoFold<State> for $Struct<$($T,)*>
impl<State: ?Sized + syn::fold::Fold, $($T,)*> $crate::fold::DoFold<State>
for $Struct<$($T,)*>
where
$($T: $crate::fold::DoFold<State>,)*
$($where)*
@ -107,7 +108,8 @@ macro_rules! impl_fold {
)
$(where ($($where:tt)*))?;
) => {
impl<State: ?Sized + syn::fold::Fold, $($T,)*> $crate::fold::DoFold<State> for $Struct<$($T,)*>
impl<State: ?Sized + syn::fold::Fold, $($T,)*> $crate::fold::DoFold<State>
for $Struct<$($T,)*>
where
$($T: $crate::fold::DoFold<State>,)*
$($where)*
@ -133,7 +135,8 @@ macro_rules! impl_fold {
))?,)*
}
) => {
impl<State: ?Sized + syn::fold::Fold, $($T,)*> $crate::fold::DoFold<State> for $Enum<$($T,)*>
impl<State: ?Sized + syn::fold::Fold, $($T,)*> $crate::fold::DoFold<State>
for $Enum<$($T,)*>
where
$($T: $crate::fold::DoFold<State>,)*
$($where)*

View file

@ -504,7 +504,10 @@ macro_rules! options {
separator.to_tokens(tokens);
separator = Some(Default::default());
v.0.to_tokens(tokens);
$(v.1.surround(tokens, |tokens| <$value as quote::ToTokens>::to_tokens(&v.2, tokens));)?
$(v.1.surround(
tokens,
|tokens| <$value as quote::ToTokens>::to_tokens(&v.2, tokens),
);)?
})*
}
}

View file

@ -353,7 +353,10 @@ macro_rules! make_builder_method_enum {
})+
Err(lookahead.error())
}
$vis fn parse_dot_prefixed(input: ParseStream, $($parse_arg: $parse_arg_ty),+) -> syn::Result<(Token![.], Self)> {
$vis fn parse_dot_prefixed(
input: ParseStream,
$($parse_arg: $parse_arg_ty,)+
) -> syn::Result<(Token![.], Self)> {
let dot = input.parse()?;
Ok((dot, Self::parse(input, $($parse_arg),+)?))
}
@ -1380,7 +1383,10 @@ impl Visitor {
Sign::Plus => (false, value.magnitude().to_bytes_le()),
};
Some(parse_quote_spanned! {span=>
::fayalite::int::make_int_literal::<#signed, #width>(#negative, &[#(#bytes,)*]).to_int_expr()
::fayalite::int::make_int_literal::<#signed, #width>(
#negative,
&[#(#bytes,)*],
).to_int_expr()
})
}
fn process_literal(&mut self, literal: ExprLit) -> Expr {

View file

@ -607,14 +607,18 @@ impl Visitor {
);
parse_quote_spanned! {span=>
{
type __MatchTy<V> = <<V as ::fayalite::expr::ToExpr>::Type as ::fayalite::ty::Type>::MatchVariant;
type __MatchTy<V> =
<<V as ::fayalite::expr::ToExpr>::Type as ::fayalite::ty::Type>::MatchVariant;
let __match_expr = ::fayalite::expr::ToExpr::to_expr(&(#expr));
::fayalite::expr::check_match_expr(__match_expr, |__match_value, __infallible| {
#[allow(unused_variables)]
#check_match
});
for __match_variant in m.match_(__match_expr) {
let (__match_variant, __scope) = ::fayalite::ty::MatchVariantAndInactiveScope::match_activate_scope(__match_variant);
let (__match_variant, __scope) =
::fayalite::ty::MatchVariantAndInactiveScope::match_activate_scope(
__match_variant,
);
#match_token __match_variant {
#(#arms)*
}

View file

@ -187,10 +187,21 @@ impl ValueDeriveGenerics {
let fixed_type_predicates = &mut fixed_type_generics.make_where_clause().predicates;
for type_param in type_params {
predicates.push(parse_quote! {#type_param: ::fayalite::ty::Value});
predicates.push(parse_quote! {<#type_param as ::fayalite::expr::ToExpr>::Type: ::fayalite::ty::Type<Value = #type_param>});
predicates.push(parse_quote! {
<#type_param as ::fayalite::expr::ToExpr>::Type:
::fayalite::ty::Type<Value = #type_param>
});
fixed_type_predicates.push(parse_quote! {#type_param: ::fayalite::ty::Value});
fixed_type_predicates.push(parse_quote! {<#type_param as ::fayalite::expr::ToExpr>::Type: ::fayalite::ty::FixedType<Value = #type_param>});
fixed_type_predicates.push(parse_quote! {<<#type_param as ::fayalite::expr::ToExpr>::Type as ::fayalite::ty::Type>::MaskType: ::fayalite::ty::FixedType});
fixed_type_predicates.push(parse_quote! {
<#type_param as ::fayalite::expr::ToExpr>::Type:
::fayalite::ty::FixedType<Value = #type_param>
});
fixed_type_predicates.push(parse_quote! {
<
<#type_param as ::fayalite::expr::ToExpr>::Type
as ::fayalite::ty::Type
>::MaskType: ::fayalite::ty::FixedType
});
}
}
Self {
@ -241,8 +252,10 @@ pub(crate) fn derive_clone_hash_eq_partialeq_for_struct<Name: ToTokens>(
#[allow(unused_variables)]
#[allow(clippy::nonminimal_bool)]
fn eq(&self, other: &Self) -> ::fayalite::__std::primitive::bool {
true
#(&& ::fayalite::__std::cmp::PartialEq::eq(&self.#field_names, &other.#field_names))*
true #(&& ::fayalite::__std::cmp::PartialEq::eq(
&self.#field_names,
&other.#field_names,
))*
}
}
}
@ -543,8 +556,22 @@ impl ToTokens for BuilderWithFields {
quote_spanned! {span=>
#[automatically_derived]
#[allow(non_camel_case_types, dead_code)]
impl<#phantom_type_param #(, #initial_type_params)* #(, #final_type_params)*> #struct_name<#phantom_type_param #(, #initial_type_params)*, () #(, #final_type_params)*> {
#vis fn #builder_field_name<#type_param>(self, #builder_field_name: #type_param) -> #struct_name<#phantom_type_param #(, #initial_type_params)*, #mapped_type #(, #final_type_params)*>
impl<#phantom_type_param #(, #initial_type_params)* #(, #final_type_params)*>
#struct_name<
#phantom_type_param,
#(#initial_type_params,)*
(), #(#final_type_params,)*
>
{
#vis fn #builder_field_name<#type_param>(
self,
#builder_field_name: #type_param,
) -> #struct_name<
#phantom_type_param,
#(#initial_type_params,)*
#mapped_type,
#(#final_type_params,)*
>
#where_clause
{
let Self {
@ -738,7 +765,8 @@ pub(crate) fn make_connect_impl(
quote_spanned! {span=>
#[automatically_derived]
#[allow(non_camel_case_types)]
impl #impl_generics ::fayalite::ty::Connect<#ty_ident #rhs_type_generics> for #ty_ident #lhs_type_generics
impl #impl_generics ::fayalite::ty::Connect<#ty_ident #rhs_type_generics>
for #ty_ident #lhs_type_generics
#where_clause
{
}

View file

@ -323,7 +323,9 @@ impl ToTokens for ParsedEnum {
f.debug_struct(#debug_ident).finish()
},
FieldsKind::Named(_) => quote! {
f.debug_struct(#debug_ident)#(.field(#field_name_strs, &self.#field_names))*.finish()
f.debug_struct(#debug_ident)
#(.field(#field_name_strs, &self.#field_names))*
.finish()
},
FieldsKind::Unnamed(_) => quote! {
f.debug_tuple(#debug_ident)#(.field(&self.#field_names))*.finish()
@ -332,17 +334,25 @@ impl ToTokens for ParsedEnum {
let value_struct_ident = &value_struct.ident;
quote! {
#[automatically_derived]
impl #fixed_type_impl_generics ::fayalite::__std::fmt::Debug for #value_struct_ident #fixed_type_type_generics
impl #fixed_type_impl_generics ::fayalite::__std::fmt::Debug
for #value_struct_ident #fixed_type_type_generics
#fixed_type_where_clause
{
fn fmt(&self, f: &mut ::fayalite::__std::fmt::Formatter<'_>) -> ::fayalite::__std::fmt::Result {
fn fmt(
&self,
f: &mut ::fayalite::__std::fmt::Formatter<'_>,
) -> ::fayalite::__std::fmt::Result {
#debug_body
}
}
}.to_tokens(tokens);
Some(
parse_quote! { <#value_struct_ident #fixed_type_type_generics as ::fayalite::expr::ToExpr>::Type },
)
}
.to_tokens(tokens);
Some(parse_quote! {
<
#value_struct_ident #fixed_type_type_generics
as ::fayalite::expr::ToExpr
>::Type
})
};
let type_struct_variants = Punctuated::from_iter(variants.iter().filter_map(|variant| {
let VariantOptions {} = variant.options.body;
@ -382,7 +392,9 @@ impl ToTokens for ParsedEnum {
let non_empty_variant_name_strs =
Vec::from_iter(non_empty_variant_names.iter().map(|v| v.to_string()));
let debug_type_body = quote! {
f.debug_struct(#type_struct_debug_ident)#(.field(#non_empty_variant_name_strs, &self.#non_empty_variant_names))*.finish()
f.debug_struct(#type_struct_debug_ident)
#(.field(#non_empty_variant_name_strs, &self.#non_empty_variant_names))*
.finish()
};
derive_clone_hash_eq_partialeq_for_struct(
type_struct_ident,
@ -415,13 +427,18 @@ impl ToTokens for ParsedEnum {
parsed_struct,
} => {
let value_struct_ident = &value_struct.ident;
let phantom_field_name = &parsed_struct.fields.last().expect("missing phantom field").name;
let phantom_field_name = &parsed_struct
.fields
.last()
.expect("missing phantom field")
.name;
let type_generics = fixed_type_type_generics.as_turbofish();
quote! {
::fayalite::__std::option::Option::Some(
::fayalite::ty::DynValueTrait::to_canonical_dyn(
&#value_struct_ident #type_generics {
#(#field_names: ::fayalite::__std::clone::Clone::clone(#var_names),)*
#(#field_names:
::fayalite::__std::clone::Clone::clone(#var_names),)*
#phantom_field_name: ::fayalite::__std::marker::PhantomData,
},
),
@ -453,7 +470,10 @@ impl ToTokens for ParsedEnum {
},
|t| {
parse_quote_spanned! {t.span()=>
::fayalite::expr::Expr<<<#t as ::fayalite::expr::ToExpr>::Type as ::fayalite::ty::Type>::Value>
::fayalite::expr::Expr<<
<#t as ::fayalite::expr::ToExpr>::Type
as ::fayalite::ty::Type
>::Value>
}
},
|t| {
@ -549,7 +569,8 @@ impl ToTokens for ParsedEnum {
});
if let Some(value_ty) = variant.value.value_ty() {
from_canonical_type_variant_lets.push(quote! {
let #variant_var = #variant_var.from_canonical_type_helper_has_value(#variant_name_str);
let #variant_var =
#variant_var.from_canonical_type_helper_has_value(#variant_name_str);
});
non_empty_variant_vars.push(variant_var.clone());
enum_type_variants.push(quote! {
@ -564,7 +585,9 @@ impl ToTokens for ParsedEnum {
::fayalite::enum_::VariantType {
name: ::fayalite::intern::Intern::intern(#variant_name_str),
ty: ::fayalite::__std::option::Option::Some(
::fayalite::bundle::TypeHint::<<#value_ty as ::fayalite::expr::ToExpr>::Type>::intern_dyn(),
::fayalite::bundle::TypeHint::<
<#value_ty as ::fayalite::expr::ToExpr>::Type,
>::intern_dyn(),
),
}
});
@ -604,12 +627,14 @@ impl ToTokens for ParsedEnum {
} => quote! {
#variant_index => {
let __variant_access = ::fayalite::expr::ToExpr::to_expr(
&__variant_access.downcast_unchecked::<
<#ident #fixed_type_type_generics as ::fayalite::expr::ToExpr>::Type,
>(),
&__variant_access.downcast_unchecked::<<
#ident #fixed_type_type_generics
as ::fayalite::expr::ToExpr
>::Type>(),
);
#match_enum_ident::#variant_name {
#(#match_enum_field_names: (*__variant_access).#match_enum_field_names,)*
#(#match_enum_field_names:
(*__variant_access).#match_enum_field_names,)*
}
},
},
@ -634,7 +659,9 @@ impl ToTokens for ParsedEnum {
VariantValue::None => parse_quote! {
{
::fayalite::expr::ToExpr::to_expr(
&::fayalite::expr::ops::EnumLiteral::<#type_struct_ident #fixed_type_type_generics>::new_unchecked(
&::fayalite::expr::ops::EnumLiteral::<
#type_struct_ident #fixed_type_type_generics
>::new_unchecked(
::fayalite::__std::option::Option::None,
#variant_index,
::fayalite::ty::FixedType::fixed_type(),
@ -645,8 +672,12 @@ impl ToTokens for ParsedEnum {
VariantValue::Direct { value_type: _ } => parse_quote! {
{
::fayalite::expr::ToExpr::to_expr(
&::fayalite::expr::ops::EnumLiteral::<#type_struct_ident #fixed_type_type_generics>::new_unchecked(
::fayalite::__std::option::Option::Some(#(#builder_field_vars)*.to_canonical_dyn()),
&::fayalite::expr::ops::EnumLiteral::<
#type_struct_ident #fixed_type_type_generics
>::new_unchecked(
::fayalite::__std::option::Option::Some(
#(#builder_field_vars)*.to_canonical_dyn(),
),
#variant_index,
::fayalite::ty::FixedType::fixed_type(),
),
@ -666,11 +697,18 @@ impl ToTokens for ParsedEnum {
..
} => parse_quote! {
{
let __builder = <#field_type_struct_ident #fixed_type_type_generics as ::fayalite::bundle::BundleType>::builder();
let __builder = <
#field_type_struct_ident #fixed_type_type_generics
as ::fayalite::bundle::BundleType
>::builder();
#(let __builder = __builder.#builder_field_vars(#builder_field_vars);)*
::fayalite::expr::ToExpr::to_expr(
&::fayalite::expr::ops::EnumLiteral::<#type_struct_ident #fixed_type_type_generics>::new_unchecked(
::fayalite::__std::option::Option::Some(__builder.build().to_canonical_dyn()),
&::fayalite::expr::ops::EnumLiteral::<
#type_struct_ident #fixed_type_type_generics
>::new_unchecked(
::fayalite::__std::option::Option::Some(
__builder.build().to_canonical_dyn(),
),
#variant_index,
::fayalite::ty::FixedType::fixed_type(),
),
@ -728,10 +766,14 @@ impl ToTokens for ParsedEnum {
let empty_builder_ty = builder.ty([], Some(&parse_quote! { Self }), false);
quote! {
#[automatically_derived]
impl #fixed_type_impl_generics ::fayalite::__std::fmt::Debug for #match_enum_ident #fixed_type_type_generics
impl #fixed_type_impl_generics ::fayalite::__std::fmt::Debug
for #match_enum_ident #fixed_type_type_generics
#fixed_type_where_clause
{
fn fmt(&self, f: &mut ::fayalite::__std::fmt::Formatter<'_>) -> ::fayalite::__std::fmt::Result {
fn fmt(
&self,
f: &mut ::fayalite::__std::fmt::Formatter<'_>,
) -> ::fayalite::__std::fmt::Result {
match *self {
#(#match_enum_debug_arms)*
}
@ -739,7 +781,8 @@ impl ToTokens for ParsedEnum {
}
#[automatically_derived]
impl #fixed_type_impl_generics ::fayalite::ty::FixedType for #type_struct_ident #fixed_type_type_generics
impl #fixed_type_impl_generics ::fayalite::ty::FixedType
for #type_struct_ident #fixed_type_type_generics
#fixed_type_where_clause
{
fn fixed_type() -> Self {
@ -760,16 +803,21 @@ impl ToTokens for ParsedEnum {
}
#[automatically_derived]
impl #fixed_type_impl_generics ::fayalite::__std::fmt::Debug for #type_struct_ident #fixed_type_type_generics
impl #fixed_type_impl_generics ::fayalite::__std::fmt::Debug
for #type_struct_ident #fixed_type_type_generics
#fixed_type_where_clause
{
fn fmt(&self, f: &mut ::fayalite::__std::fmt::Formatter<'_>) -> ::fayalite::__std::fmt::Result {
fn fmt(
&self,
f: &mut ::fayalite::__std::fmt::Formatter<'_>,
) -> ::fayalite::__std::fmt::Result {
#debug_type_body
}
}
#[automatically_derived]
impl #fixed_type_impl_generics ::fayalite::ty::Type for #type_struct_ident #fixed_type_type_generics
impl #fixed_type_impl_generics ::fayalite::ty::Type
for #type_struct_ident #fixed_type_type_generics
#fixed_type_where_clause
{
type CanonicalType = ::fayalite::enum_::DynEnumType;
@ -779,15 +827,20 @@ impl ToTokens for ParsedEnum {
type MaskValue = ::fayalite::int::UInt<1>;
type MatchVariant = #match_enum_ident #fixed_type_type_generics;
type MatchActiveScope = ::fayalite::module::Scope;
type MatchVariantAndInactiveScope = ::fayalite::enum_::EnumMatchVariantAndInactiveScope<Self>;
type MatchVariantAndInactiveScope =
::fayalite::enum_::EnumMatchVariantAndInactiveScope<Self>;
type MatchVariantsIter = ::fayalite::enum_::EnumMatchVariantsIter<Self>;
fn match_variants<IO: ::fayalite::bundle::BundleValue>(
this: ::fayalite::expr::Expr<<Self as ::fayalite::ty::Type>::Value>,
module_builder: &mut ::fayalite::module::ModuleBuilder<IO, ::fayalite::module::NormalModule>,
module_builder: &mut ::fayalite::module::ModuleBuilder<
IO,
::fayalite::module::NormalModule,
>,
source_location: ::fayalite::source_location::SourceLocation,
) -> <Self as ::fayalite::ty::Type>::MatchVariantsIter
where
<IO as ::fayalite::expr::ToExpr>::Type: ::fayalite::bundle::BundleType<Value = IO>,
<IO as ::fayalite::expr::ToExpr>::Type:
::fayalite::bundle::BundleType<Value = IO>,
{
module_builder.enum_match_variants_helper(this, source_location)
}
@ -818,16 +871,22 @@ impl ToTokens for ParsedEnum {
#[automatically_derived]
#[allow(clippy::init_numbered_fields)]
impl #fixed_type_impl_generics ::fayalite::enum_::EnumType for #type_struct_ident #fixed_type_type_generics
impl #fixed_type_impl_generics ::fayalite::enum_::EnumType
for #type_struct_ident #fixed_type_type_generics
#fixed_type_where_clause
{
type Builder = #empty_builder_ty;
fn match_activate_scope(
v: <Self as ::fayalite::ty::Type>::MatchVariantAndInactiveScope,
) -> (<Self as ::fayalite::ty::Type>::MatchVariant, <Self as ::fayalite::ty::Type>::MatchActiveScope) {
) -> (
<Self as ::fayalite::ty::Type>::MatchVariant,
<Self as ::fayalite::ty::Type>::MatchActiveScope,
) {
let (__variant_access, __scope) = v.activate();
(
match ::fayalite::expr::ops::VariantAccess::variant_index(&*__variant_access) {
match ::fayalite::expr::ops::VariantAccess::variant_index(
&*__variant_access,
) {
#(#match_enum_arms)*
#variant_count.. => ::fayalite::__std::panic!("invalid variant index"),
},
@ -837,7 +896,9 @@ impl ToTokens for ParsedEnum {
fn builder() -> <Self as ::fayalite::enum_::EnumType>::Builder {
#empty_builder_ty::new()
}
fn variants(&self) -> ::fayalite::intern::Interned<[::fayalite::enum_::VariantType<::fayalite::intern::Interned<dyn ::fayalite::ty::DynCanonicalType>>]> {
fn variants(&self) -> ::fayalite::intern::Interned<[::fayalite::enum_::VariantType<
::fayalite::intern::Interned<dyn ::fayalite::ty::DynCanonicalType>,
>]> {
::fayalite::intern::Intern::intern(&[#(#enum_type_variants,)*][..])
}
fn variants_hint() -> ::fayalite::enum_::VariantsHint {
@ -846,7 +907,8 @@ impl ToTokens for ParsedEnum {
}
#[automatically_derived]
impl #fixed_type_impl_generics ::fayalite::expr::ToExpr for #target #fixed_type_type_generics
impl #fixed_type_impl_generics ::fayalite::expr::ToExpr
for #target #fixed_type_type_generics
#fixed_type_where_clause
{
type Type = #type_struct_ident #fixed_type_type_generics;
@ -859,10 +921,15 @@ impl ToTokens for ParsedEnum {
}
#[automatically_derived]
impl #fixed_type_impl_generics ::fayalite::ty::Value for #target #fixed_type_type_generics
impl #fixed_type_impl_generics ::fayalite::ty::Value
for #target #fixed_type_type_generics
#fixed_type_where_clause
{
fn to_canonical(&self) -> <<Self as ::fayalite::expr::ToExpr>::Type as ::fayalite::ty::Type>::CanonicalValue {
fn to_canonical(&self) -> <
<Self as ::fayalite::expr::ToExpr>::Type
as ::fayalite::ty::Type
>::CanonicalValue
{
let __ty = ::fayalite::ty::Type::canonical(&::fayalite::expr::ToExpr::ty(self));
match self {
#(Self::#variant_names { #variant_field_pats } => {
@ -877,7 +944,8 @@ impl ToTokens for ParsedEnum {
}
#[automatically_derived]
impl #fixed_type_impl_generics ::fayalite::enum_::EnumValue for #target #fixed_type_type_generics
impl #fixed_type_impl_generics ::fayalite::enum_::EnumValue
for #target #fixed_type_type_generics
#fixed_type_where_clause
{
}

View file

@ -303,25 +303,35 @@ impl ParsedStruct {
f.debug_struct(#mask_value_debug_ident).finish()
},
FieldsKind::Named(_) => quote! {
f.debug_struct(#mask_value_debug_ident)#(.field(#unskipped_field_name_strs, &self.#unskipped_field_names))*.finish()
f.debug_struct(#mask_value_debug_ident)
#(.field(#unskipped_field_name_strs, &self.#unskipped_field_names))*
.finish()
},
FieldsKind::Unnamed(_) => quote! {
f.debug_tuple(#mask_value_debug_ident)#(.field(&self.#unskipped_field_names))*.finish()
f.debug_tuple(#mask_value_debug_ident)
#(.field(&self.#unskipped_field_names))*
.finish()
},
};
quote! {
#[automatically_derived]
impl #impl_generics ::fayalite::__std::fmt::Debug for #mask_value_ident #type_generics
impl #impl_generics ::fayalite::__std::fmt::Debug
for #mask_value_ident #type_generics
#where_clause
{
fn fmt(&self, f: &mut ::fayalite::__std::fmt::Formatter<'_>) -> ::fayalite::__std::fmt::Result {
fn fmt(
&self,
f: &mut ::fayalite::__std::fmt::Formatter<'_>,
) -> ::fayalite::__std::fmt::Result {
#debug_mask_value_body
}
}
}.to_tokens(tokens);
}
.to_tokens(tokens);
quote! {
#mask_type_ident {
#(#unskipped_field_names: ::fayalite::ty::Type::mask_type(&self.#unskipped_field_names),)*
#(#unskipped_field_names:
::fayalite::ty::Type::mask_type(&self.#unskipped_field_names),)*
#(#phantom_data_field_name_slice: ::fayalite::__std::marker::PhantomData,)*
}
}
@ -331,10 +341,14 @@ impl ParsedStruct {
f.debug_struct(#type_struct_debug_ident).finish()
},
FieldsKind::Named(_) => quote! {
f.debug_struct(#type_struct_debug_ident)#(.field(#unskipped_field_name_strs, &self.#unskipped_field_names))*.finish()
f.debug_struct(#type_struct_debug_ident)
#(.field(#unskipped_field_name_strs, &self.#unskipped_field_names))*
.finish()
},
FieldsKind::Unnamed(_) => quote! {
f.debug_tuple(#type_struct_debug_ident)#(.field(&self.#unskipped_field_names))*.finish()
f.debug_tuple(#type_struct_debug_ident)
#(.field(&self.#unskipped_field_names))*
.finish()
},
};
for the_struct_ident in [&type_struct_ident, match_variant_ident]
@ -369,7 +383,8 @@ impl ParsedStruct {
fn fixed_type() -> Self {
Self {
#(#unskipped_field_names: ::fayalite::ty::FixedType::fixed_type(),)*
#(#phantom_data_field_name_slice: ::fayalite::__std::marker::PhantomData,)*
#(#phantom_data_field_name_slice:
::fayalite::__std::marker::PhantomData,)*
}
}
}
@ -393,24 +408,27 @@ impl ParsedStruct {
let mut builder = Builder::new(builder_struct_ident.clone(), vis.clone());
for field in unskipped_fields.clone() {
builder.insert_field(
field.name.clone(),
|v| {
parse_quote_spanned! {v.span()=>
::fayalite::expr::ToExpr::to_expr(&#v)
}
},
|t| {
parse_quote_spanned! {t.span()=>
::fayalite::expr::Expr<<<#t as ::fayalite::expr::ToExpr>::Type as ::fayalite::ty::Type>::Value>
}
},
|t| {
parse_quote_spanned! {t.span()=>
where
#t: ::fayalite::expr::ToExpr,
}
},
);
field.name.clone(),
|v| {
parse_quote_spanned! {v.span()=>
::fayalite::expr::ToExpr::to_expr(&#v)
}
},
|t| {
parse_quote_spanned! {t.span()=>
::fayalite::expr::Expr<<
<#t as ::fayalite::expr::ToExpr>::Type
as ::fayalite::ty::Type
>::Value>
}
},
|t| {
parse_quote_spanned! {t.span()=>
where
#t: ::fayalite::expr::ToExpr,
}
},
);
}
let builder = builder.finish_filling_in_fields();
builder.to_tokens(tokens);
@ -456,7 +474,8 @@ impl ParsedStruct {
)*][..]),
#type_struct_ident {
#(#build_type_fields,)*
#(#phantom_data_field_name_slice: ::fayalite::__std::marker::PhantomData,)*
#(#phantom_data_field_name_slice:
::fayalite::__std::marker::PhantomData,)*
},
),
)
@ -494,7 +513,10 @@ impl ParsedStruct {
impl #impl_generics ::fayalite::__std::fmt::Debug for #type_struct_ident #type_generics
#where_clause
{
fn fmt(&self, f: &mut ::fayalite::__std::fmt::Formatter<'_>) -> ::fayalite::__std::fmt::Result {
fn fmt(
&self,
f: &mut ::fayalite::__std::fmt::Formatter<'_>,
) -> ::fayalite::__std::fmt::Result {
#debug_type_body
}
}
@ -510,21 +532,32 @@ impl ParsedStruct {
type MaskValue = #mask_value_ident #type_generics;
type MatchVariant = #match_variant_ident #type_generics;
type MatchActiveScope = ();
type MatchVariantAndInactiveScope = ::fayalite::ty::MatchVariantWithoutScope<#match_variant_ident #type_generics>;
type MatchVariantsIter = ::fayalite::__std::iter::Once<<Self as ::fayalite::ty::Type>::MatchVariantAndInactiveScope>;
type MatchVariantAndInactiveScope = ::fayalite::ty::MatchVariantWithoutScope<
#match_variant_ident #type_generics,
>;
type MatchVariantsIter = ::fayalite::__std::iter::Once<
<Self as ::fayalite::ty::Type>::MatchVariantAndInactiveScope,
>;
#[allow(unused_variables)]
fn match_variants<IO: ::fayalite::bundle::BundleValue>(
this: ::fayalite::expr::Expr<<Self as ::fayalite::ty::Type>::Value>,
module_builder: &mut ::fayalite::module::ModuleBuilder<IO, ::fayalite::module::NormalModule>,
module_builder: &mut ::fayalite::module::ModuleBuilder<
IO,
::fayalite::module::NormalModule,
>,
source_location: ::fayalite::source_location::SourceLocation,
) -> <Self as ::fayalite::ty::Type>::MatchVariantsIter
where
<IO as ::fayalite::expr::ToExpr>::Type: ::fayalite::bundle::BundleType<Value = IO>,
<IO as ::fayalite::expr::ToExpr>::Type:
::fayalite::bundle::BundleType<Value = IO>,
{
::fayalite::__std::iter::once(::fayalite::ty::MatchVariantWithoutScope(#match_variant_ident {
#(#unskipped_field_names: this.field(#unskipped_field_name_strs),)*
#(#phantom_data_field_name_slice: ::fayalite::__std::marker::PhantomData,)*
}))
::fayalite::__std::iter::once(::fayalite::ty::MatchVariantWithoutScope(
#match_variant_ident {
#(#unskipped_field_names: this.field(#unskipped_field_name_strs),)*
#(#phantom_data_field_name_slice:
::fayalite::__std::marker::PhantomData,)*
},
))
}
fn mask_type(&self) -> <Self as ::fayalite::ty::Type>::MaskType {
#mask_type_body
@ -540,11 +573,15 @@ impl ParsedStruct {
::fayalite::ty::TypeEnum::BundleType(::fayalite::ty::Type::canonical(self))
}
fn from_canonical_type(t: <Self as ::fayalite::ty::Type>::CanonicalType) -> Self {
let [#(#unskipped_field_vars),*] = *::fayalite::bundle::BundleType::fields(&t) else {
let [#(#unskipped_field_vars),*] = *::fayalite::bundle::BundleType::fields(&t)
else {
::fayalite::__std::panic!("wrong number of fields");
};
Self {
#(#unskipped_field_names: #unskipped_field_vars.from_canonical_type_helper(#unskipped_field_name_strs, #unskipped_field_flips),)*
#(#unskipped_field_names: #unskipped_field_vars.from_canonical_type_helper(
#unskipped_field_name_strs,
#unskipped_field_flips,
),)*
#(#phantom_data_field_name_slice: ::fayalite::__std::marker::PhantomData,)*
}
}
@ -555,13 +592,16 @@ impl ParsedStruct {
#where_clause
{
#[allow(unused_variables)]
fn expr_deref(this: &::fayalite::expr::Expr<<Self as ::fayalite::ty::Type>::Value>) -> &<Self as ::fayalite::ty::Type>::MatchVariant {
::fayalite::intern::Interned::<_>::into_inner(::fayalite::intern::Intern::intern_sized(
#match_variant_ident {
fn expr_deref(this: &::fayalite::expr::Expr<<Self as ::fayalite::ty::Type>::Value>)
-> &<Self as ::fayalite::ty::Type>::MatchVariant
{
::fayalite::intern::Interned::<_>::into_inner(
::fayalite::intern::Intern::intern_sized(#match_variant_ident {
#(#unskipped_field_names: this.field(#unskipped_field_name_strs),)*
#(#phantom_data_field_name_slice: ::fayalite::__std::marker::PhantomData,)*
}
))
#(#phantom_data_field_name_slice:
::fayalite::__std::marker::PhantomData,)*
}),
)
}
}
@ -573,12 +613,19 @@ impl ParsedStruct {
fn builder() -> <Self as ::fayalite::bundle::BundleType>::Builder {
#empty_builder_ty::new()
}
fn fields(&self) -> ::fayalite::intern::Interned<[::fayalite::bundle::FieldType<::fayalite::intern::Interned<dyn ::fayalite::ty::DynCanonicalType>>]> {
fn fields(&self) -> ::fayalite::intern::Interned<
[::fayalite::bundle::FieldType<::fayalite::intern::Interned<
dyn ::fayalite::ty::DynCanonicalType,
>>],
>
{
::fayalite::intern::Intern::intern(&[#(
::fayalite::bundle::FieldType {
name: ::fayalite::intern::Intern::intern(#unskipped_field_name_strs),
flipped: #unskipped_field_flips,
ty: ::fayalite::ty::DynType::canonical_dyn(&self.#unskipped_field_names),
ty: ::fayalite::ty::DynType::canonical_dyn(
&self.#unskipped_field_names,
),
},
)*][..])
}
@ -600,7 +647,9 @@ impl ParsedStruct {
type Type = #type_struct_ident #type_generics;
fn ty(&self) -> <Self as ::fayalite::expr::ToExpr>::Type {
#type_struct_ident {
#(#unskipped_field_names: ::fayalite::expr::ToExpr::ty(&self.#unskipped_field_names),)*
#(#unskipped_field_names: ::fayalite::expr::ToExpr::ty(
&self.#unskipped_field_names,
),)*
#(#phantom_data_field_name_slice: ::fayalite::__std::marker::PhantomData,)*
}
}
@ -613,10 +662,16 @@ impl ParsedStruct {
impl #impl_generics ::fayalite::ty::Value for #target #type_generics
#where_clause
{
fn to_canonical(&self) -> <<Self as ::fayalite::expr::ToExpr>::Type as ::fayalite::ty::Type>::CanonicalValue {
fn to_canonical(&self) -> <
<Self as ::fayalite::expr::ToExpr>::Type
as ::fayalite::ty::Type
>::CanonicalValue
{
let ty = ::fayalite::ty::Type::canonical(&::fayalite::expr::ToExpr::ty(self));
::fayalite::bundle::DynBundle::new(ty, ::fayalite::__std::sync::Arc::new([
#(::fayalite::ty::DynValueTrait::to_canonical_dyn(&self.#unskipped_field_names),)*
#(::fayalite::ty::DynValueTrait::to_canonical_dyn(
&self.#unskipped_field_names,
),)*
]))
}
}