forked from libre-chip/fayalite
rename FixedType->StaticType, fixed_type()->static_type(), hdl(fixed_type)->hdl(static), IsFixedLen->IsStaticLen
This commit is contained in:
parent
c19a6821cf
commit
2dce478d48
20 changed files with 165 additions and 164 deletions
|
@ -248,5 +248,6 @@ no_op_fold!(syn::Token![enum]);
|
|||
no_op_fold!(syn::Token![extern]);
|
||||
no_op_fold!(syn::Token![let]);
|
||||
no_op_fold!(syn::Token![mut]);
|
||||
no_op_fold!(syn::Token![static]);
|
||||
no_op_fold!(syn::Token![struct]);
|
||||
no_op_fold!(syn::Token![where]);
|
||||
|
|
|
@ -20,7 +20,7 @@ mod value_derive_struct;
|
|||
|
||||
mod kw {
|
||||
pub(crate) use syn::token::{
|
||||
Enum as enum_, Extern as extern_, Struct as struct_, Where as where_,
|
||||
Enum as enum_, Extern as extern_, Static as static_, Struct as struct_, Where as where_,
|
||||
};
|
||||
|
||||
macro_rules! custom_keyword {
|
||||
|
@ -43,7 +43,6 @@ mod kw {
|
|||
|
||||
custom_keyword!(clock_domain);
|
||||
custom_keyword!(connect_inexact);
|
||||
custom_keyword!(fixed_type);
|
||||
custom_keyword!(flip);
|
||||
custom_keyword!(hdl);
|
||||
custom_keyword!(input);
|
||||
|
|
|
@ -312,9 +312,9 @@ impl ModuleFn {
|
|||
#body_fn
|
||||
::fayalite::module::ModuleBuilder::run(#fn_name_str, |m| __body #body_turbofish_type_generics(m, #(#param_names,)*))
|
||||
}};
|
||||
let fixed_type = io.iter().all(|io| io.kind.ty_expr.is_none());
|
||||
let struct_options = if fixed_type {
|
||||
quote! { #[hdl(fixed_type)] }
|
||||
let static_type = io.iter().all(|io| io.kind.ty_expr.is_none());
|
||||
let struct_options = if static_type {
|
||||
quote! { #[hdl(static)] }
|
||||
} else {
|
||||
quote! {}
|
||||
};
|
||||
|
|
|
@ -1003,10 +1003,10 @@ fn wrap_ty_with_expr(ty: impl ToTokens) -> Type {
|
|||
}
|
||||
}
|
||||
|
||||
fn unwrap_or_fixed_type(expr: Option<impl ToTokens>, span: Span) -> TokenStream {
|
||||
fn unwrap_or_static_type(expr: Option<impl ToTokens>, span: Span) -> TokenStream {
|
||||
expr.map(ToTokens::into_token_stream).unwrap_or_else(|| {
|
||||
quote_spanned! {span=>
|
||||
::fayalite::ty::FixedType::fixed_type()
|
||||
::fayalite::ty::StaticType::static_type()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -1109,7 +1109,7 @@ impl Visitor {
|
|||
let m = hdl_let.kind.m;
|
||||
let dot = hdl_let.kind.dot_token;
|
||||
let kind = hdl_let.kind.kind;
|
||||
let ty_expr = unwrap_or_fixed_type(hdl_let.kind.ty_expr.as_ref(), kind.span());
|
||||
let ty_expr = unwrap_or_static_type(hdl_let.kind.ty_expr.as_ref(), kind.span());
|
||||
let mut expr = quote! {#m #dot #kind};
|
||||
hdl_let.kind.paren.surround(&mut expr, |expr| {
|
||||
let name_str = ImplicitName {
|
||||
|
@ -1214,7 +1214,7 @@ impl Visitor {
|
|||
paren,
|
||||
ty_expr,
|
||||
} => {
|
||||
let ty_expr = unwrap_or_fixed_type(ty_expr.as_ref(), reg_builder.span());
|
||||
let ty_expr = unwrap_or_static_type(ty_expr.as_ref(), reg_builder.span());
|
||||
dot_token.to_tokens(&mut expr);
|
||||
no_reset.to_tokens(&mut expr);
|
||||
paren.surround(&mut expr, |expr| ty_expr.to_tokens(expr));
|
||||
|
@ -1248,7 +1248,7 @@ impl Visitor {
|
|||
let dot = hdl_let.kind.dot_token;
|
||||
let wire = hdl_let.kind.wire;
|
||||
self.require_normal_module(wire);
|
||||
let ty_expr = unwrap_or_fixed_type(hdl_let.kind.ty_expr.as_ref(), wire.span());
|
||||
let ty_expr = unwrap_or_static_type(hdl_let.kind.ty_expr.as_ref(), wire.span());
|
||||
let mut expr = quote! {#m #dot #wire};
|
||||
hdl_let.kind.paren.surround(&mut expr, |expr| {
|
||||
let name_str = ImplicitName {
|
||||
|
@ -1290,14 +1290,14 @@ impl Visitor {
|
|||
memory,
|
||||
paren,
|
||||
ty_expr,
|
||||
} => (paren, unwrap_or_fixed_type(ty_expr.as_ref(), memory.span())),
|
||||
} => (paren, unwrap_or_static_type(ty_expr.as_ref(), memory.span())),
|
||||
MemoryFn::MemoryArray {
|
||||
memory_array,
|
||||
paren,
|
||||
ty_expr,
|
||||
} => (
|
||||
paren,
|
||||
unwrap_or_fixed_type(ty_expr.as_ref(), memory_array.span()),
|
||||
unwrap_or_static_type(ty_expr.as_ref(), memory_array.span()),
|
||||
),
|
||||
MemoryFn::MemoryWithInit {
|
||||
memory_with_init: _,
|
||||
|
|
|
@ -167,46 +167,46 @@ pub(crate) fn get_target(target: &Option<(kw::target, Paren, Path)>, item_ident:
|
|||
|
||||
pub(crate) struct ValueDeriveGenerics {
|
||||
pub(crate) generics: Generics,
|
||||
pub(crate) fixed_type_generics: Generics,
|
||||
pub(crate) static_type_generics: Generics,
|
||||
}
|
||||
|
||||
impl ValueDeriveGenerics {
|
||||
pub(crate) fn get(mut generics: Generics, where_: &Option<(Where, Paren, Bounds)>) -> Self {
|
||||
let mut fixed_type_generics = generics.clone();
|
||||
let mut static_type_generics = generics.clone();
|
||||
if let Some((_, _, bounds)) = where_ {
|
||||
generics
|
||||
.make_where_clause()
|
||||
.predicates
|
||||
.extend(bounds.0.iter().cloned());
|
||||
fixed_type_generics
|
||||
static_type_generics
|
||||
.where_clause
|
||||
.clone_from(&generics.where_clause);
|
||||
} else {
|
||||
let type_params = Vec::from_iter(generics.type_params().map(|v| v.ident.clone()));
|
||||
let predicates = &mut generics.make_where_clause().predicates;
|
||||
let fixed_type_predicates = &mut fixed_type_generics.make_where_clause().predicates;
|
||||
let static_type_predicates = &mut static_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>
|
||||
});
|
||||
fixed_type_predicates.push(parse_quote! {#type_param: ::fayalite::ty::Value});
|
||||
fixed_type_predicates.push(parse_quote! {
|
||||
static_type_predicates.push(parse_quote! {#type_param: ::fayalite::ty::Value});
|
||||
static_type_predicates.push(parse_quote! {
|
||||
<#type_param as ::fayalite::expr::ToExpr>::Type:
|
||||
::fayalite::ty::FixedType<Value = #type_param>
|
||||
::fayalite::ty::StaticType<Value = #type_param>
|
||||
});
|
||||
fixed_type_predicates.push(parse_quote! {
|
||||
static_type_predicates.push(parse_quote! {
|
||||
<
|
||||
<#type_param as ::fayalite::expr::ToExpr>::Type
|
||||
as ::fayalite::ty::Type
|
||||
>::MaskType: ::fayalite::ty::FixedType
|
||||
>::MaskType: ::fayalite::ty::StaticType
|
||||
});
|
||||
}
|
||||
}
|
||||
Self {
|
||||
generics,
|
||||
fixed_type_generics,
|
||||
static_type_generics,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -152,7 +152,7 @@ impl ParsedVariant {
|
|||
parsed_struct: ParsedStruct {
|
||||
options: StructOptions {
|
||||
outline_generated: None,
|
||||
fixed_type: Some(Default::default()),
|
||||
static_: Some(Default::default()),
|
||||
where_: Some((
|
||||
Default::default(),
|
||||
Default::default(),
|
||||
|
@ -160,7 +160,7 @@ impl ParsedVariant {
|
|||
enum_generics.clone(),
|
||||
&enum_options.where_,
|
||||
)
|
||||
.fixed_type_generics
|
||||
.static_type_generics
|
||||
.where_clause
|
||||
.into(),
|
||||
)),
|
||||
|
@ -275,10 +275,10 @@ impl ToTokens for ParsedEnum {
|
|||
let target = get_target(target, enum_ident);
|
||||
let ValueDeriveGenerics {
|
||||
generics: _,
|
||||
fixed_type_generics,
|
||||
static_type_generics,
|
||||
} = ValueDeriveGenerics::get(enum_generics.clone(), where_);
|
||||
let (fixed_type_impl_generics, fixed_type_type_generics, fixed_type_where_clause) =
|
||||
fixed_type_generics.split_for_impl();
|
||||
let (static_type_impl_generics, static_type_type_generics, static_type_where_clause) =
|
||||
static_type_generics.split_for_impl();
|
||||
let type_struct_ident = format_ident!("__{}__Type", enum_ident);
|
||||
let mut field_checks = vec![];
|
||||
let mut make_type_struct_variant_type = |variant: &ParsedVariant| {
|
||||
|
@ -303,7 +303,7 @@ impl ToTokens for ParsedEnum {
|
|||
let mut field_names = Vec::from_iter(get_field_names(&value_struct.fields));
|
||||
derive_clone_hash_eq_partialeq_for_struct(
|
||||
&value_struct.ident,
|
||||
&fixed_type_generics,
|
||||
&static_type_generics,
|
||||
&field_names,
|
||||
)
|
||||
.to_tokens(tokens);
|
||||
|
@ -334,9 +334,9 @@ 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
|
||||
#fixed_type_where_clause
|
||||
impl #static_type_impl_generics ::fayalite::__std::fmt::Debug
|
||||
for #value_struct_ident #static_type_type_generics
|
||||
#static_type_where_clause
|
||||
{
|
||||
fn fmt(
|
||||
&self,
|
||||
|
@ -349,7 +349,7 @@ impl ToTokens for ParsedEnum {
|
|||
.to_tokens(tokens);
|
||||
Some(parse_quote! {
|
||||
<
|
||||
#value_struct_ident #fixed_type_type_generics
|
||||
#value_struct_ident #static_type_type_generics
|
||||
as ::fayalite::expr::ToExpr
|
||||
>::Type
|
||||
})
|
||||
|
@ -373,7 +373,7 @@ impl ToTokens for ParsedEnum {
|
|||
vis: vis.clone(),
|
||||
struct_token: Token,
|
||||
ident: type_struct_ident,
|
||||
generics: fixed_type_generics.clone(),
|
||||
generics: static_type_generics.clone(),
|
||||
fields: Fields::Named(FieldsNamed {
|
||||
brace_token: *brace_token,
|
||||
named: type_struct_variants,
|
||||
|
@ -398,7 +398,7 @@ impl ToTokens for ParsedEnum {
|
|||
};
|
||||
derive_clone_hash_eq_partialeq_for_struct(
|
||||
type_struct_ident,
|
||||
&fixed_type_generics,
|
||||
&static_type_generics,
|
||||
&non_empty_variant_names,
|
||||
)
|
||||
.to_tokens(tokens);
|
||||
|
@ -432,7 +432,7 @@ impl ToTokens for ParsedEnum {
|
|||
.last()
|
||||
.expect("missing phantom field")
|
||||
.name;
|
||||
let type_generics = fixed_type_type_generics.as_turbofish();
|
||||
let type_generics = static_type_type_generics.as_turbofish();
|
||||
quote! {
|
||||
::fayalite::__std::option::Option::Some(
|
||||
::fayalite::ty::DynValueTrait::to_canonical_dyn(
|
||||
|
@ -628,7 +628,7 @@ impl ToTokens for ParsedEnum {
|
|||
#variant_index => {
|
||||
let __variant_access = ::fayalite::expr::ToExpr::to_expr(
|
||||
&__variant_access.downcast_unchecked::<<
|
||||
#ident #fixed_type_type_generics
|
||||
#ident #static_type_type_generics
|
||||
as ::fayalite::expr::ToExpr
|
||||
>::Type>(),
|
||||
);
|
||||
|
@ -660,11 +660,11 @@ impl ToTokens for ParsedEnum {
|
|||
{
|
||||
::fayalite::expr::ToExpr::to_expr(
|
||||
&::fayalite::expr::ops::EnumLiteral::<
|
||||
#type_struct_ident #fixed_type_type_generics
|
||||
#type_struct_ident #static_type_type_generics
|
||||
>::new_unchecked(
|
||||
::fayalite::__std::option::Option::None,
|
||||
#variant_index,
|
||||
::fayalite::ty::FixedType::fixed_type(),
|
||||
::fayalite::ty::StaticType::static_type(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -673,13 +673,13 @@ impl ToTokens for ParsedEnum {
|
|||
{
|
||||
::fayalite::expr::ToExpr::to_expr(
|
||||
&::fayalite::expr::ops::EnumLiteral::<
|
||||
#type_struct_ident #fixed_type_type_generics
|
||||
#type_struct_ident #static_type_type_generics
|
||||
>::new_unchecked(
|
||||
::fayalite::__std::option::Option::Some(
|
||||
#(#builder_field_vars)*.to_canonical_dyn(),
|
||||
),
|
||||
#variant_index,
|
||||
::fayalite::ty::FixedType::fixed_type(),
|
||||
::fayalite::ty::StaticType::static_type(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -698,19 +698,19 @@ impl ToTokens for ParsedEnum {
|
|||
} => parse_quote! {
|
||||
{
|
||||
let __builder = <
|
||||
#field_type_struct_ident #fixed_type_type_generics
|
||||
#field_type_struct_ident #static_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
|
||||
#type_struct_ident #static_type_type_generics
|
||||
>::new_unchecked(
|
||||
::fayalite::__std::option::Option::Some(
|
||||
__builder.build().to_canonical_dyn(),
|
||||
),
|
||||
#variant_index,
|
||||
::fayalite::ty::FixedType::fixed_type(),
|
||||
::fayalite::ty::StaticType::static_type(),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
@ -730,9 +730,9 @@ impl ToTokens for ParsedEnum {
|
|||
(name.clone(), parse_quote! { ::fayalite::expr::Expr<#ty> })
|
||||
},
|
||||
),
|
||||
&fixed_type_generics,
|
||||
&parse_quote! {#type_struct_ident #fixed_type_type_generics},
|
||||
&parse_quote! { ::fayalite::expr::Expr<#target #fixed_type_type_generics> },
|
||||
&static_type_generics,
|
||||
&parse_quote! {#type_struct_ident #static_type_type_generics},
|
||||
&parse_quote! { ::fayalite::expr::Expr<#target #static_type_type_generics> },
|
||||
build_body,
|
||||
)
|
||||
.to_tokens(tokens);
|
||||
|
@ -742,7 +742,7 @@ impl ToTokens for ParsedEnum {
|
|||
vis: vis.clone(),
|
||||
enum_token: *enum_token,
|
||||
ident: match_enum_ident,
|
||||
generics: fixed_type_generics.clone(),
|
||||
generics: static_type_generics.clone(),
|
||||
brace_token: *brace_token,
|
||||
variants: match_enum_variants,
|
||||
};
|
||||
|
@ -750,7 +750,7 @@ impl ToTokens for ParsedEnum {
|
|||
match_enum.to_tokens(tokens);
|
||||
make_connect_impl(
|
||||
*connect_inexact,
|
||||
&fixed_type_generics,
|
||||
&static_type_generics,
|
||||
type_struct_ident,
|
||||
variants.iter().flat_map(|variant| {
|
||||
variant.fields.iter().map(|field| {
|
||||
|
@ -766,9 +766,9 @@ 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
|
||||
#fixed_type_where_clause
|
||||
impl #static_type_impl_generics ::fayalite::__std::fmt::Debug
|
||||
for #match_enum_ident #static_type_type_generics
|
||||
#static_type_where_clause
|
||||
{
|
||||
fn fmt(
|
||||
&self,
|
||||
|
@ -781,13 +781,13 @@ impl ToTokens for ParsedEnum {
|
|||
}
|
||||
|
||||
#[automatically_derived]
|
||||
impl #fixed_type_impl_generics ::fayalite::ty::FixedType
|
||||
for #type_struct_ident #fixed_type_type_generics
|
||||
#fixed_type_where_clause
|
||||
impl #static_type_impl_generics ::fayalite::ty::StaticType
|
||||
for #type_struct_ident #static_type_type_generics
|
||||
#static_type_where_clause
|
||||
{
|
||||
fn fixed_type() -> Self {
|
||||
fn static_type() -> Self {
|
||||
Self {
|
||||
#(#non_empty_variant_names: ::fayalite::ty::FixedType::fixed_type(),)*
|
||||
#(#non_empty_variant_names: ::fayalite::ty::StaticType::static_type(),)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -796,16 +796,16 @@ impl ToTokens for ParsedEnum {
|
|||
where
|
||||
<T as ::fayalite::expr::ToExpr>::Type: ::fayalite::ty::Type<Value = T>,
|
||||
{}
|
||||
fn __check_fields #fixed_type_impl_generics(_: #target #fixed_type_type_generics)
|
||||
#fixed_type_where_clause
|
||||
fn __check_fields #static_type_impl_generics(_: #target #static_type_type_generics)
|
||||
#static_type_where_clause
|
||||
{
|
||||
#(#field_checks)*
|
||||
}
|
||||
|
||||
#[automatically_derived]
|
||||
impl #fixed_type_impl_generics ::fayalite::__std::fmt::Debug
|
||||
for #type_struct_ident #fixed_type_type_generics
|
||||
#fixed_type_where_clause
|
||||
impl #static_type_impl_generics ::fayalite::__std::fmt::Debug
|
||||
for #type_struct_ident #static_type_type_generics
|
||||
#static_type_where_clause
|
||||
{
|
||||
fn fmt(
|
||||
&self,
|
||||
|
@ -816,16 +816,16 @@ impl ToTokens for ParsedEnum {
|
|||
}
|
||||
|
||||
#[automatically_derived]
|
||||
impl #fixed_type_impl_generics ::fayalite::ty::Type
|
||||
for #type_struct_ident #fixed_type_type_generics
|
||||
#fixed_type_where_clause
|
||||
impl #static_type_impl_generics ::fayalite::ty::Type
|
||||
for #type_struct_ident #static_type_type_generics
|
||||
#static_type_where_clause
|
||||
{
|
||||
type CanonicalType = ::fayalite::enum_::DynEnumType;
|
||||
type Value = #target #fixed_type_type_generics;
|
||||
type Value = #target #static_type_type_generics;
|
||||
type CanonicalValue = ::fayalite::enum_::DynEnum;
|
||||
type MaskType = ::fayalite::int::UIntType<1>;
|
||||
type MaskValue = ::fayalite::int::UInt<1>;
|
||||
type MatchVariant = #match_enum_ident #fixed_type_type_generics;
|
||||
type MatchVariant = #match_enum_ident #static_type_type_generics;
|
||||
type MatchActiveScope = ::fayalite::module::Scope;
|
||||
type MatchVariantAndInactiveScope =
|
||||
::fayalite::enum_::EnumMatchVariantAndInactiveScope<Self>;
|
||||
|
@ -871,9 +871,9 @@ 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
|
||||
#fixed_type_where_clause
|
||||
impl #static_type_impl_generics ::fayalite::enum_::EnumType
|
||||
for #type_struct_ident #static_type_type_generics
|
||||
#static_type_where_clause
|
||||
{
|
||||
type Builder = #empty_builder_ty;
|
||||
fn match_activate_scope(
|
||||
|
@ -907,13 +907,13 @@ impl ToTokens for ParsedEnum {
|
|||
}
|
||||
|
||||
#[automatically_derived]
|
||||
impl #fixed_type_impl_generics ::fayalite::expr::ToExpr
|
||||
for #target #fixed_type_type_generics
|
||||
#fixed_type_where_clause
|
||||
impl #static_type_impl_generics ::fayalite::expr::ToExpr
|
||||
for #target #static_type_type_generics
|
||||
#static_type_where_clause
|
||||
{
|
||||
type Type = #type_struct_ident #fixed_type_type_generics;
|
||||
type Type = #type_struct_ident #static_type_type_generics;
|
||||
fn ty(&self) -> <Self as ::fayalite::expr::ToExpr>::Type {
|
||||
::fayalite::ty::FixedType::fixed_type()
|
||||
::fayalite::ty::StaticType::static_type()
|
||||
}
|
||||
fn to_expr(&self) -> ::fayalite::expr::Expr<Self> {
|
||||
::fayalite::expr::Expr::from_value(self)
|
||||
|
@ -921,9 +921,9 @@ impl ToTokens for ParsedEnum {
|
|||
}
|
||||
|
||||
#[automatically_derived]
|
||||
impl #fixed_type_impl_generics ::fayalite::ty::Value
|
||||
for #target #fixed_type_type_generics
|
||||
#fixed_type_where_clause
|
||||
impl #static_type_impl_generics ::fayalite::ty::Value
|
||||
for #target #static_type_type_generics
|
||||
#static_type_where_clause
|
||||
{
|
||||
fn to_canonical(&self) -> <
|
||||
<Self as ::fayalite::expr::ToExpr>::Type
|
||||
|
@ -944,9 +944,9 @@ impl ToTokens for ParsedEnum {
|
|||
}
|
||||
|
||||
#[automatically_derived]
|
||||
impl #fixed_type_impl_generics ::fayalite::enum_::EnumValue
|
||||
for #target #fixed_type_type_generics
|
||||
#fixed_type_where_clause
|
||||
impl #static_type_impl_generics ::fayalite::enum_::EnumValue
|
||||
for #target #static_type_type_generics
|
||||
#static_type_where_clause
|
||||
{
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ crate::options! {
|
|||
#[options = StructOptions]
|
||||
pub(crate) enum StructOption {
|
||||
OutlineGenerated(outline_generated),
|
||||
FixedType(fixed_type),
|
||||
Static(static_),
|
||||
ConnectInexact(connect_inexact),
|
||||
Bounds(where_, Bounds),
|
||||
Target(target, Path),
|
||||
|
@ -136,12 +136,12 @@ impl ParsedStruct {
|
|||
outline_generated: _,
|
||||
where_,
|
||||
target: _,
|
||||
fixed_type,
|
||||
static_,
|
||||
connect_inexact,
|
||||
} = &options.body;
|
||||
let ValueDeriveGenerics {
|
||||
generics,
|
||||
fixed_type_generics,
|
||||
static_type_generics,
|
||||
} = ValueDeriveGenerics::get(generics.clone(), where_);
|
||||
let (impl_generics, type_generics, where_clause) = generics.split_for_impl();
|
||||
let unskipped_fields = fields
|
||||
|
@ -373,16 +373,17 @@ impl ParsedStruct {
|
|||
__check_field(#check_v.#name);
|
||||
}
|
||||
}));
|
||||
if fixed_type.is_some() {
|
||||
let (impl_generics, type_generics, where_clause) = fixed_type_generics.split_for_impl();
|
||||
if static_.is_some() {
|
||||
let (impl_generics, type_generics, where_clause) =
|
||||
static_type_generics.split_for_impl();
|
||||
quote! {
|
||||
#[automatically_derived]
|
||||
impl #impl_generics ::fayalite::ty::FixedType for #type_struct_ident #type_generics
|
||||
impl #impl_generics ::fayalite::ty::StaticType for #type_struct_ident #type_generics
|
||||
#where_clause
|
||||
{
|
||||
fn fixed_type() -> Self {
|
||||
fn static_type() -> Self {
|
||||
Self {
|
||||
#(#unskipped_field_names: ::fayalite::ty::FixedType::fixed_type(),)*
|
||||
#(#unskipped_field_names: ::fayalite::ty::StaticType::static_type(),)*
|
||||
#(#phantom_data_field_name_slice:
|
||||
::fayalite::__std::marker::PhantomData,)*
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue