reformat messy code that rustfmt doesn't format
All checks were successful
/ test (push) Successful in 9m17s

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,
),)*
]))
}
}

View file

@ -66,7 +66,12 @@ impl DefinitionState {
let folder_fn_name = self.folder_fn_name();
let (impl_generics, type_generics, where_clause) = self.folder_generics.split_for_impl();
quote! {
fn #folder_fn_name #impl_generics(&mut self, v: #path #type_generics) -> Result<#path #type_generics, Self::Error> #where_clause {
fn #folder_fn_name #impl_generics(
&mut self,
v: #path #type_generics,
) -> Result<#path #type_generics, Self::Error>
#where_clause
{
Fold::default_fold(v, self)
}
}
@ -75,7 +80,12 @@ impl DefinitionState {
let visitor_fn_name = self.visitor_fn_name();
let (impl_generics, type_generics, where_clause) = self.visitor_generics.split_for_impl();
quote! {
fn #visitor_fn_name #impl_generics(&mut self, v: &#path #type_generics) -> Result<(), Self::Error> #where_clause {
fn #visitor_fn_name #impl_generics(
&mut self,
v: &#path #type_generics,
) -> Result<(), Self::Error>
#where_clause
{
Visit::default_visit(v, self)
}
}
@ -87,7 +97,9 @@ impl DefinitionState {
quote! {
#[automatically_derived]
#[allow(clippy::init_numbered_fields)]
impl #trait_impl_generics Fold<State> for #path #self_type_generics #trait_where_clause {
impl #trait_impl_generics Fold<State> for #path #self_type_generics
#trait_where_clause
{
fn fold(self, state: &mut State) -> Result<Self, State::Error> {
state.#folder_fn_name(self)
}
@ -103,7 +115,9 @@ impl DefinitionState {
let (trait_impl_generics, _, trait_where_clause) = self.visit_generics.split_for_impl();
quote! {
#[automatically_derived]
impl #trait_impl_generics Visit<State> for #path #self_type_generics #trait_where_clause {
impl #trait_impl_generics Visit<State> for #path #self_type_generics
#trait_where_clause
{
fn visit(&self, state: &mut State) -> Result<(), State::Error> {
state.#visitor_fn_name(self)
}
@ -257,7 +271,13 @@ pub fn generate(ast: &ast::Definitions) -> syn::Result<String> {
} else {
let member = field_name.to_member();
if member.is_none() {
return Err(syn::Error::new(Span::call_site(), format!("struct must have `$constructor` since it contains a non-plain field: {def_path:?} {field_name:?}")));
return Err(syn::Error::new(
Span::call_site(),
format!(
"struct must have `$constructor` since it contains a \
non-plain field: {def_path:?} {field_name:?}"
),
));
}
member
};
@ -342,7 +362,8 @@ pub fn generate(ast: &ast::Definitions) -> syn::Result<String> {
Some(ast::Field::Visible) => {
state_unused = false;
fold_arm = quote! {
Self::#variant_name(v) => Fold::fold(v, state).map(Self::#variant_name),
Self::#variant_name(v) => Fold::fold(v, state)
.map(Self::#variant_name),
};
visit_arm = quote! {
Self::#variant_name(v) => Visit::visit(v, state),

View file

@ -564,8 +564,18 @@ macro_rules! impl_tuple_builder {
$(($after_Ts $after_fields $after_members))*
]);
impl<Phantom, $($before_Ts,)* $($after_Ts,)*> $builder<Phantom, $($before_Ts,)* () $(, $after_Ts)*> {
pub fn $field<$T: ToExpr>(self, $field: $T) -> $builder<Phantom, $($before_Ts,)* Expr<<$T::Type as Type>::Value> $(, $after_Ts)*> {
impl<Phantom, $($before_Ts,)* $($after_Ts,)*> $builder<
Phantom,
$($before_Ts,)*
(),
$($after_Ts,)*
> {
pub fn $field<$T: ToExpr>(self, $field: $T) -> $builder<
Phantom,
$($before_Ts,)*
Expr<<$T::Type as Type>::Value>,
$($after_Ts,)*
> {
let Self {
$($before_fields,)*
$field: _,

View file

@ -208,7 +208,8 @@ macro_rules! unary_op {
).ty,
#[cache]
literal_bits: Result<Interned<BitSlice>, ()> = {
arg.to_literal_bits().map(|v| ops::$Op::$op($T::CanonicalValue::from_bit_slice(&v)).to_bits())
arg.to_literal_bits()
.map(|v| ops::$Op::$op($T::CanonicalValue::from_bit_slice(&v)).to_bits())
},
fn simulate(&self, sim_state: &mut SimState) -> _ {
@ -242,7 +243,10 @@ unary_op! {
#[method = not]
impl<T> Not for _
where (
T: IntTypeTrait<CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>>,
T: IntTypeTrait<
CanonicalType = DynIntType<<T as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<T as IntTypeTrait>::Signed>,
>,
)
{
fn expr_enum(&self) -> _ {
@ -262,7 +266,11 @@ unary_op! {
#[method = neg]
impl<T> Neg for _
where (
T: IntTypeTrait<Signed = ConstBool<true>, CanonicalType = DynSIntType, CanonicalValue = DynSInt>,
T: IntTypeTrait<
Signed = ConstBool<true>,
CanonicalType = DynSIntType,
CanonicalValue = DynSInt,
>,
)
{
fn expr_enum(&self) -> _ {
@ -273,7 +281,12 @@ unary_op! {
macro_rules! binary_op {
(
#[method = $op:ident, rhs_to_canonical_dyn = $rhs_to_canonical_dyn:ident, expr_enum_u = $expr_enum_u:ident, expr_enum_s = $expr_enum_s:ident]
#[
method = $op:ident,
rhs_to_canonical_dyn = $rhs_to_canonical_dyn:ident,
expr_enum_u = $expr_enum_u:ident,
expr_enum_s = $expr_enum_s:ident
]
impl<$LhsType:ident, $RhsType:ident> $Op:ident for _ where $($where:tt)*
) => {
fixed_ary_op! {
@ -285,7 +298,10 @@ macro_rules! binary_op {
pub lhs: Expr<$LhsType::CanonicalValue>,
pub rhs: Expr<$RhsType::CanonicalValue>,
#[type]
ty: <<Valueless<$LhsType> as ops::$Op<Valueless<$RhsType>>>::Output as ValuelessTr>::Type = ops::$Op::$op(
ty: <
<Valueless<$LhsType> as ops::$Op<Valueless<$RhsType>>>::Output
as ValuelessTr
>::Type = ops::$Op::$op(
Valueless::<$LhsType>::from_canonical(lhs.valueless()),
Valueless::<$RhsType>::from_canonical(rhs.valueless()),
).ty,
@ -309,7 +325,8 @@ macro_rules! binary_op {
fn expr_enum(&self) -> _ {
struct Tag;
impl ConstBoolDispatchTag for Tag {
type Type<Select: GenericConstBool> = $Op<DynIntType<Select>, DynIntType<Select>>;
type Type<Select: GenericConstBool> =
$Op<DynIntType<Select>, DynIntType<Select>>;
}
match ConstBoolDispatch::new::<Tag, $LhsType::Signed>(self.canonical()) {
ConstBoolDispatch::False(v) => ExprEnum::$expr_enum_u(v.intern_sized()),
@ -322,25 +339,45 @@ macro_rules! binary_op {
}
}
impl<Lhs: Value<Type = $LhsType>, $LhsType, $RhsType, Rhs: Value<Type = $RhsType>> ops::$Op<Expr<Rhs>> for Expr<Lhs>
impl<
Lhs: Value<Type = $LhsType>,
$LhsType,
$RhsType,
Rhs: Value<Type = $RhsType>,
> ops::$Op<Expr<Rhs>> for Expr<Lhs>
where
$($where)*
{
type Output = Expr<<<Valueless<$LhsType> as ops::$Op<Valueless<$RhsType>>>::Output as ValuelessTr>::Value>;
type Output = Expr<<
<Valueless<$LhsType> as ops::$Op<Valueless<$RhsType>>>::Output
as ValuelessTr
>::Value>;
fn $op(self, rhs: Expr<Rhs>) -> Self::Output {
$Op::<$LhsType, $RhsType>::new_unchecked(self.canonical(), rhs.canonical()).to_expr()
$Op::<$LhsType, $RhsType>::new_unchecked(self.canonical(), rhs.canonical())
.to_expr()
}
}
impl<Lhs: Value<Type = $LhsType>, $LhsType, $RhsType, Rhs: Value<Type = $RhsType>> ops::$Op<Rhs> for Expr<Lhs>
impl<
Lhs: Value<Type = $LhsType>,
$LhsType,
$RhsType,
Rhs: Value<Type = $RhsType>,
> ops::$Op<Rhs> for Expr<Lhs>
where
$($where)*
{
type Output = Expr<<<Valueless<$LhsType> as ops::$Op<Valueless<$RhsType>>>::Output as ValuelessTr>::Value>;
type Output = Expr<<
<Valueless<$LhsType> as ops::$Op<Valueless<$RhsType>>>::Output
as ValuelessTr
>::Value>;
fn $op(self, rhs: Rhs) -> Self::Output {
$Op::<$LhsType, $RhsType>::new_unchecked(self.canonical(), rhs.to_expr().canonical()).to_expr()
$Op::<$LhsType, $RhsType>::new_unchecked(
self.canonical(),
rhs.to_expr().canonical(),
).to_expr()
}
}
@ -348,78 +385,156 @@ macro_rules! binary_op {
where
$($where)*
{
type Output = Expr<<<Valueless<$LhsType> as ops::$Op<Valueless<$RhsType>>>::Output as ValuelessTr>::Value>;
type Output = Expr<<
<Valueless<$LhsType> as ops::$Op<Valueless<$RhsType>>>::Output
as ValuelessTr
>::Value>;
fn $op(self, rhs: Expr<Rhs>) -> Self::Output {
$Op::<$LhsType, $RhsType>::new_unchecked(self.to_expr().canonical(), rhs.canonical()).to_expr()
$Op::<$LhsType, $RhsType>::new_unchecked(
self.to_expr().canonical(),
rhs.canonical(),
).to_expr()
}
}
};
}
binary_op! {
#[method = bitand, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = BitAndU, expr_enum_s = BitAndS]
#[
method = bitand,
rhs_to_canonical_dyn = to_canonical_dyn,
expr_enum_u = BitAndU,
expr_enum_s = BitAndS
]
impl<L, R> BitAnd for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait<
CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>,
>,
R: IntTypeTrait<
Signed = L::Signed,
CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>,
>,
}
binary_op! {
#[method = bitor, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = BitOrU, expr_enum_s = BitOrS]
#[
method = bitor,
rhs_to_canonical_dyn = to_canonical_dyn,
expr_enum_u = BitOrU,
expr_enum_s = BitOrS
]
impl<L, R> BitOr for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait<
CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>,
>,
R: IntTypeTrait<
Signed = L::Signed,
CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>,
>,
}
binary_op! {
#[method = bitxor, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = BitXorU, expr_enum_s = BitXorS]
#[
method = bitxor,
rhs_to_canonical_dyn = to_canonical_dyn,
expr_enum_u = BitXorU,
expr_enum_s = BitXorS
]
impl<L, R> BitXor for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait<
CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>,
>,
R: IntTypeTrait<
Signed = L::Signed,
CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>,
>,
}
binary_op! {
#[method = add, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = AddU, expr_enum_s = AddS]
impl<L, R> Add for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait<
CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>,
>,
R: IntTypeTrait<
Signed = L::Signed,
CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>,
>,
}
binary_op! {
#[method = sub, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = SubU, expr_enum_s = SubS]
impl<L, R> Sub for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait<
CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>,
>,
R: IntTypeTrait<
Signed = L::Signed,
CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>,
>,
}
binary_op! {
#[method = mul, rhs_to_canonical_dyn = to_canonical_dyn, expr_enum_u = MulU, expr_enum_s = MulS]
#[
method = mul,
rhs_to_canonical_dyn = to_canonical_dyn,
expr_enum_u = MulU,
expr_enum_s = MulS
]
impl<L, R> Mul for _
where
L: IntTypeTrait<CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>>,
R: IntTypeTrait<Signed = L::Signed, CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>>,
L: IntTypeTrait<
CanonicalType = DynIntType<<L as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<L as IntTypeTrait>::Signed>,
>,
R: IntTypeTrait<
Signed = L::Signed,
CanonicalType = DynIntType<<R as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<R as IntTypeTrait>::Signed>,
>,
}
macro_rules! dyn_shift_op {
(
#[method = $Op:ident::$op:ident, expr_enum_u = $expr_enum_u:ident, expr_enum_s = $expr_enum_s:ident]
#[
method = $Op:ident::$op:ident,
expr_enum_u = $expr_enum_u:ident,
expr_enum_s = $expr_enum_s:ident
]
impl $DynOp:ident
) => {
fixed_ary_op! {
pub struct $DynOp<LhsType,>
where (
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
LhsType: IntTypeTrait<
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
)
{
pub lhs: Expr<LhsType::CanonicalValue>,
pub rhs: Expr<DynUInt>,
#[type]
ty: <<Valueless<LhsType> as ops::$Op<Valueless<DynUIntType>>>::Output as ValuelessTr>::Type = ops::$Op::$op(
ty: <
<Valueless<LhsType> as ops::$Op<Valueless<DynUIntType>>>::Output
as ValuelessTr
>::Type = ops::$Op::$op(
lhs.valueless(),
rhs.valueless(),
).ty,
@ -456,12 +571,27 @@ macro_rules! dyn_shift_op {
}
}
impl<Lhs: Value<Type = LhsType>, LhsType, RhsType, Rhs: Value<Type = RhsType>> ops::$Op<Expr<Rhs>> for Expr<Lhs>
impl<
Lhs: Value<Type = LhsType>,
LhsType,
RhsType,
Rhs: Value<Type = RhsType>,
> ops::$Op<Expr<Rhs>> for Expr<Lhs>
where
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
RhsType: IntTypeTrait<Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>,
LhsType: IntTypeTrait<
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
{
type Output = Expr<<<Valueless<LhsType> as ops::$Op<Valueless<RhsType>>>::Output as ValuelessTr>::Value>;
type Output = Expr<<
<Valueless<LhsType> as ops::$Op<Valueless<RhsType>>>::Output
as ValuelessTr
>::Value>;
fn $op(self, rhs: Expr<Rhs>) -> Self::Output {
$DynOp::<LhsType>::new_unchecked(self.canonical(), rhs.canonical()).to_expr()
@ -470,13 +600,23 @@ macro_rules! dyn_shift_op {
impl<LhsType, RhsType, Rhs: Value<Type = RhsType>> ops::$Op<Expr<Rhs>> for IntValue<LhsType>
where
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
RhsType: IntTypeTrait<Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>,
LhsType: IntTypeTrait<
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
{
type Output = Expr<<<Valueless<LhsType> as ops::$Op<Valueless<RhsType>>>::Output as ValuelessTr>::Value>;
type Output = Expr<<
<Valueless<LhsType> as ops::$Op<Valueless<RhsType>>>::Output as ValuelessTr>::Value,
>;
fn $op(self, rhs: Expr<Rhs>) -> Self::Output {
$DynOp::<LhsType>::new_unchecked(self.to_expr().canonical(), rhs.canonical()).to_expr()
$DynOp::<LhsType>::new_unchecked(self.to_expr().canonical(), rhs.canonical())
.to_expr()
}
}
};
@ -484,22 +624,27 @@ macro_rules! dyn_shift_op {
macro_rules! fixed_shift_op {
(
#[method = $Op:ident::$op:ident, expr_enum_u = $expr_enum_u:ident, expr_enum_s = $expr_enum_s:ident]
#[
method = $Op:ident::$op:ident,
expr_enum_u = $expr_enum_u:ident,
expr_enum_s = $expr_enum_s:ident
]
impl $FixedOp:ident
) => {
fixed_ary_op! {
pub struct $FixedOp<LhsType,>
where (
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
LhsType: IntTypeTrait<
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
)
{
pub lhs: Expr<LhsType::CanonicalValue>,
pub rhs: usize,
#[type]
ty: <<Valueless<LhsType> as ops::$Op<usize>>::Output as ValuelessTr>::Type = ops::$Op::$op(
lhs.valueless(),
rhs,
).ty,
ty: <<Valueless<LhsType> as ops::$Op<usize>>::Output as ValuelessTr>::Type =
ops::$Op::$op(lhs.valueless(), rhs).ty,
#[cache]
literal_bits: Result<Interned<BitSlice>, ()> = {
lhs.to_literal_bits()
@ -532,9 +677,13 @@ macro_rules! fixed_shift_op {
impl<Lhs: Value<Type = LhsType>, LhsType> ops::$Op<usize> for Expr<Lhs>
where
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
LhsType: IntTypeTrait<
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
{
type Output = Expr<<<Valueless<LhsType> as ops::$Op<usize>>::Output as ValuelessTr>::Value>;
type Output =
Expr<<<Valueless<LhsType> as ops::$Op<usize>>::Output as ValuelessTr>::Value>;
fn $op(self, rhs: usize) -> Self::Output {
$FixedOp::<LhsType>::new_unchecked(self.canonical(), rhs).to_expr()
@ -568,9 +717,21 @@ macro_rules! cmp_op {
$(fixed_ary_op! {
pub struct $CmpOp<LhsType, RhsType, Output,>
where (
LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>,
RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>,
Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>,
LhsType: IntTypeTrait<
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = LhsType::Signed,
CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>,
>,
Output: FixedOrDynIntType<
1,
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
)
{
pub lhs: Expr<LhsType::CanonicalValue>,
@ -598,7 +759,8 @@ macro_rules! cmp_op {
fn expr_enum(&self) -> _ {
struct Tag;
impl ConstBoolDispatchTag for Tag {
type Type<Select: GenericConstBool> = $CmpOp<DynIntType<Select>, DynIntType<Select>, DynUIntType>;
type Type<Select: GenericConstBool> =
$CmpOp<DynIntType<Select>, DynIntType<Select>, DynUIntType>;
}
match ConstBoolDispatch::new::<Tag, LhsType::Signed>(self.canonical()) {
ConstBoolDispatch::False(v) => ExprEnum::$CmpOpU(v.intern_sized()),
@ -612,15 +774,44 @@ macro_rules! cmp_op {
}
})*
impl<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Rhs: Value<Type = RhsType>, Lhs: Value<Type = LhsType>> IntCmp<Expr<Rhs>> for Expr<Lhs> {
impl<
LhsType: IntTypeTrait<
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = LhsType::Signed,
CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>,
>,
Rhs: Value<Type = RhsType>,
Lhs: Value<Type = LhsType>,
> IntCmp<Expr<Rhs>> for Expr<Lhs>
{
type Output = Expr<UInt<1>>;
$(fn $fn(self, rhs: Expr<Rhs>) -> Self::Output {
$CmpOp::<LhsType, RhsType, UIntType<1>>::new_unchecked(self.canonical(), rhs.canonical()).to_expr()
$CmpOp::<LhsType, RhsType, UIntType<1>>::new_unchecked(
self.canonical(),
rhs.canonical(),
).to_expr()
})*
}
impl<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Rhs: Value<Type = RhsType>, Lhs: Value<Type = LhsType>> IntCmp<Rhs> for Expr<Lhs> {
impl<
LhsType: IntTypeTrait<
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = LhsType::Signed,
CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>,
>,
Rhs: Value<Type = RhsType>,
Lhs: Value<Type = LhsType>,
> IntCmp<Rhs> for Expr<Lhs>
{
type Output = Expr<UInt<1>>;
$(fn $fn(self, rhs: Rhs) -> Self::Output {
@ -628,7 +819,18 @@ macro_rules! cmp_op {
})*
}
impl<LhsType: IntTypeTrait<CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>>, RhsType: IntTypeTrait<Signed = LhsType::Signed, CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>>, Rhs: Value<Type = RhsType>> IntCmp<Expr<Rhs>> for IntValue<LhsType> {
impl<
LhsType: IntTypeTrait<
CanonicalType = DynIntType<<LhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<LhsType as IntTypeTrait>::Signed>,
>,
RhsType: IntTypeTrait<
Signed = LhsType::Signed,
CanonicalType = DynIntType<<RhsType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<RhsType as IntTypeTrait>::Signed>,
>,
Rhs: Value<Type = RhsType>,
> IntCmp<Expr<Rhs>> for IntValue<LhsType> {
type Output = Expr<UInt<1>>;
$(fn $fn(self, rhs: Expr<Rhs>) -> Self::Output {
@ -636,7 +838,10 @@ macro_rules! cmp_op {
})*
}
impl<LhsType: IntTypeTrait, RhsType: IntTypeTrait<Signed = LhsType::Signed>> IntCmp<Valueless<RhsType>> for Valueless<LhsType> {
impl<
LhsType: IntTypeTrait,
RhsType: IntTypeTrait<Signed = LhsType::Signed>,
> IntCmp<Valueless<RhsType>> for Valueless<LhsType> {
type Output = Valueless<UIntType<1>>;
$(fn $fn(self, _rhs: Valueless<RhsType>) -> Self::Output {
@ -658,8 +863,14 @@ cmp_op! {
fixed_ary_op! {
pub struct CastInt<FromType, ToType,>
where (
FromType: IntTypeTrait<CanonicalType = DynIntType<<FromType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<FromType as IntTypeTrait>::Signed>>,
ToType: IntTypeTrait<CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>>,
FromType: IntTypeTrait<
CanonicalType = DynIntType<<FromType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<FromType as IntTypeTrait>::Signed>,
>,
ToType: IntTypeTrait<
CanonicalType = DynIntType<<ToType as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<ToType as IntTypeTrait>::Signed>,
>,
)
{
pub value: Expr<FromType::CanonicalValue>,
@ -669,7 +880,8 @@ fixed_ary_op! {
literal_bits: Result<Interned<BitSlice>, ()> = {
value.to_literal_bits().map(|literal_bits| {
let mut bits = literal_bits.to_bitvec();
let fill = FromType::Signed::VALUE && bits.len().checked_sub(1).map(|i| bits[i]).unwrap_or(false);
let fill = FromType::Signed::VALUE
&& bits.len().checked_sub(1).map(|i| bits[i]).unwrap_or(false);
bits.resize(ty.width(), fill);
Intern::intern_owned(bits)
})
@ -689,13 +901,24 @@ fixed_ary_op! {
}
struct Tag2<FromSigned: GenericConstBool>(FromSigned);
impl<FromSigned: GenericConstBool> ConstBoolDispatchTag for Tag2<FromSigned> {
type Type<Select: GenericConstBool> = CastInt<DynIntType<FromSigned>, DynIntType<Select>>;
type Type<Select: GenericConstBool> =
CastInt<DynIntType<FromSigned>, DynIntType<Select>>;
}
match ConstBoolDispatch::new::<Tag1, FromType::Signed>(ConstBoolDispatch::new::<Tag2<FromType::Signed>, ToType::Signed>(self.canonical())) {
ConstBoolDispatch::False(ConstBoolDispatch::False(v)) => ExprEnum::CastUIntToUInt(v.intern_sized()),
ConstBoolDispatch::False(ConstBoolDispatch::True(v)) => ExprEnum::CastUIntToSInt(v.intern_sized()),
ConstBoolDispatch::True(ConstBoolDispatch::False(v)) => ExprEnum::CastSIntToUInt(v.intern_sized()),
ConstBoolDispatch::True(ConstBoolDispatch::True(v)) => ExprEnum::CastSIntToSInt(v.intern_sized()),
match ConstBoolDispatch::new::<Tag1, FromType::Signed>(
ConstBoolDispatch::new::<Tag2<FromType::Signed>, ToType::Signed>(self.canonical()),
) {
ConstBoolDispatch::False(ConstBoolDispatch::False(v)) => {
ExprEnum::CastUIntToUInt(v.intern_sized())
}
ConstBoolDispatch::False(ConstBoolDispatch::True(v)) => {
ExprEnum::CastUIntToSInt(v.intern_sized())
}
ConstBoolDispatch::True(ConstBoolDispatch::False(v)) => {
ExprEnum::CastSIntToUInt(v.intern_sized())
}
ConstBoolDispatch::True(ConstBoolDispatch::True(v)) => {
ExprEnum::CastSIntToSInt(v.intern_sized())
}
}
}
@ -740,7 +963,10 @@ impl<
fixed_ary_op! {
pub struct Slice<Base,>
where (
Base: IntTypeTrait<CanonicalType = DynIntType<<Base as IntTypeTrait>::Signed>, CanonicalValue = DynInt<<Base as IntTypeTrait>::Signed>>,
Base: IntTypeTrait<
CanonicalType = DynIntType<<Base as IntTypeTrait>::Signed>,
CanonicalValue = DynInt<<Base as IntTypeTrait>::Signed>,
>,
)
{
pub base: Expr<Base::CanonicalValue>,
@ -890,7 +1116,12 @@ macro_rules! reduce_bit_op {
fixed_ary_op! {
pub struct $name<Output,>
where (
Output: FixedOrDynIntType<1, Signed = ConstBool<false>, CanonicalType = DynUIntType, CanonicalValue = DynUInt>,
Output: FixedOrDynIntType<
1,
Signed = ConstBool<false>,
CanonicalType = DynUIntType,
CanonicalValue = DynUInt,
>,
)
{
pub arg: Expr<DynUInt>,

View file

@ -2297,7 +2297,7 @@ pub struct TestBackend {
pub files: BTreeMap<String, String>,
pub error_after: Option<i64>,
#[doc(hidden)]
/// #[non_exhaustive] except allowing struct update syntax
/// `#[non_exhaustive]` except allowing struct update syntax
pub __private: TestBackendPrivate,
}

View file

@ -92,7 +92,7 @@ pub struct BuilderModuleBody {
memory_map: HashMap<ScopedNameId, Rc<RefCell<MemBuilderTarget>>>,
}
/// implicit name argument that's automatically provided by #[hdl] let
/// implicit name argument that's automatically provided by `#[hdl]` let
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
pub struct ImplicitName<'a>(pub &'a str);
@ -225,7 +225,10 @@ impl<S: ModuleBuildingStatus> fmt::Debug for StmtMatch<S> {
macro_rules! wrapper_enum {
(
#[impl(($($T_impl:tt)*) $impl_self:ident: $impl_type:ty = $impl_self_expr:expr $(, ($($T_impls:tt)*) $impls_self:ident: $impls_type:ty = $impls_self_expr:expr)*)]
#[impl(
($($T_impl:tt)*) $impl_self:ident: $impl_type:ty = $impl_self_expr:expr
$(, ($($T_impls:tt)*) $impls_self:ident: $impls_type:ty = $impls_self_expr:expr)*
)]
#[to($($T_to:tt $to_types:ty),*)]
$(#[$enum_meta:meta])*
$vis:vis enum $enum_name:ident<$T_enum:ident: $T_bound:ident = $T_enum_default:ident> {
@ -356,7 +359,10 @@ pub struct StmtInstance<S: ModuleBuildingStatus = ModuleBuilt> {
}
wrapper_enum! {
#[impl((<S: ModuleBuildingStatus>) self: StmtDeclaration<S> = self, (<S: ModuleBuildingStatus>) self: Stmt<S> = self.declaration()?)]
#[impl(
(<S: ModuleBuildingStatus>) self: StmtDeclaration<S> = self,
(<S: ModuleBuildingStatus>) self: Stmt<S> = self.declaration()?
)]
#[to((<S: ModuleBuildingStatus>) StmtDeclaration<S>, (<S: ModuleBuildingStatus>) Stmt<S>)]
#[derive(Clone, PartialEq, Eq, Hash)]
pub enum StmtDeclaration<S: ModuleBuildingStatus = ModuleBuilt> {
@ -1705,7 +1711,7 @@ impl<T: BundleValue> Module<T>
where
T::Type: BundleType<Value = T>,
{
/// you generally should use the #[hdl_module] proc-macro and [`ModuleBuilder`] instead
/// you generally should use the [`#[hdl_module]`][`crate::hdl_module`] proc-macro and [`ModuleBuilder`] instead
pub fn new_unchecked(
name_id: NameId,
source_location: SourceLocation,

View file

@ -45,20 +45,34 @@ pub trait Visit<State: ?Sized + Visitor> {
macro_rules! impl_visit_fold {
(
impl<$T:ident, $State:ident $(, const $Const:ident: $const_ty:ty)*> _ for $ty:ty $(where ($($where_tt:tt)*))? {
fn fold($($fold_args:tt)*) -> $fold_ret_ty:ty $fold_block:block
fn default_fold($($default_fold_args:tt)*) -> $default_fold_ret_ty:ty $default_fold_block:block
fn visit($($visit_args:tt)*) -> $visit_ret_ty:ty $visit_block:block
fn default_visit($($default_visit_args:tt)*) -> $default_visit_ret_ty:ty $default_visit_block:block
impl<$T:ident, $State:ident $(, const $Const:ident: $const_ty:ty)*> _ for $ty:ty
$(where ($($where_tt:tt)*))?
{
fn fold($($fold_args:tt)*) -> $fold_ret_ty:ty
$fold_block:block
fn default_fold($($default_fold_args:tt)*) -> $default_fold_ret_ty:ty
$default_fold_block:block
fn visit($($visit_args:tt)*) -> $visit_ret_ty:ty
$visit_block:block
fn default_visit($($default_visit_args:tt)*) -> $default_visit_ret_ty:ty
$default_visit_block:block
}
) => {
impl<$T: Fold<$State>, $State: ?Sized + Folder $(, const $Const: $const_ty)*> Fold<$State> for $ty
impl<
$T: Fold<$State>,
$State: ?Sized + Folder,
$(const $Const: $const_ty,)*
> Fold<$State> for $ty
$(where $($where_tt)*)?
{
fn fold($($fold_args)*) -> $fold_ret_ty $fold_block
fn default_fold($($default_fold_args)*) -> $default_fold_ret_ty $default_fold_block
}
impl<$T: Visit<$State>, $State: ?Sized + Visitor $(, const $Const: $const_ty)*> Visit<$State> for $ty
impl<
$T: Visit<$State>,
$State: ?Sized + Visitor,
$(const $Const: $const_ty,)*
> Visit<$State> for $ty
$(where $($where_tt)*)?
{
fn visit($($visit_args)*) -> $visit_ret_ty $visit_block

View file

@ -109,7 +109,9 @@ const FILE_PATTERNS: &[FilePattern] = &[
];
thread_local! {
static NORMALIZE_FILES_FOR_TESTS: RefCell<Option<NormalizeFilesForTestsState>> = const { RefCell::new(None) };
static NORMALIZE_FILES_FOR_TESTS: RefCell<Option<NormalizeFilesForTestsState>> = const {
RefCell::new(None)
};
}
impl From<&'_ panic::Location<'_>> for SourceLocation {