Fixing polymorphic enum loop build fn bug.
This commit is contained in:
parent
3159f119bc
commit
4eb48cc1a2
@ -1,8 +1,8 @@
|
||||
use crate::deserialize::util::{make_build_fn_name, make_build_pair};
|
||||
use crate::spec::polymorphic_enum_loop_spec::{
|
||||
PolymorphicEnumLoopBuildSpec, PolymorphicEnumLoopRule,
|
||||
PolymorphicEnumLoopRuleBuild, PolymorphicEnumLoopRuleBuildChild,
|
||||
PolymorphicEnumLoopRuleChildOnEach, PolymorphicEnumLoopRulePassThrough,
|
||||
PolymorphicEnumLoopBuildSpec, PolymorphicEnumLoopRule, PolymorphicEnumLoopRuleBuild,
|
||||
PolymorphicEnumLoopRuleBuildChild, PolymorphicEnumLoopRuleChildOnEach,
|
||||
PolymorphicEnumLoopRulePassThrough,
|
||||
};
|
||||
use proc_macro2::TokenStream;
|
||||
use quote::{format_ident, quote};
|
||||
@ -20,7 +20,7 @@ fn make_pass_through(pass_through: &PolymorphicEnumLoopRulePassThrough) -> Token
|
||||
fn make_on_each_child_build(child: &PolymorphicEnumLoopRuleChildOnEach) -> TokenStream {
|
||||
let child_build_fn_ident = format_ident!("{}", make_build_fn_name(child.rule()));
|
||||
quote! {
|
||||
#child_build_fn_ident(inner_pair)
|
||||
Box::new(#child_build_fn_ident(inner_pair))
|
||||
}
|
||||
}
|
||||
|
||||
@ -39,11 +39,9 @@ fn make_build(
|
||||
PolymorphicEnumLoopRuleBuildChild::OnEach(_) => true,
|
||||
_ => false,
|
||||
})
|
||||
.map(|child| {
|
||||
match child {
|
||||
PolymorphicEnumLoopRuleBuildChild::OnEach(on_each) => on_each,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
.map(|child| match child {
|
||||
PolymorphicEnumLoopRuleBuildChild::OnEach(on_each) => on_each,
|
||||
_ => unreachable!(),
|
||||
})
|
||||
.unwrap();
|
||||
|
||||
@ -53,7 +51,7 @@ fn make_build(
|
||||
.children()
|
||||
.map(|child| match child {
|
||||
PolymorphicEnumLoopRuleBuildChild::UseCurrent(_) => {
|
||||
quote! { result.unwrap() }
|
||||
quote! { Box::new(result.unwrap()) }
|
||||
}
|
||||
PolymorphicEnumLoopRuleBuildChild::OnEach(_) => quote! { on_each_child },
|
||||
})
|
||||
@ -68,7 +66,10 @@ fn make_build(
|
||||
}
|
||||
}
|
||||
|
||||
fn make_match_arm(spec: &PolymorphicEnumLoopBuildSpec, rule: &PolymorphicEnumLoopRule) -> TokenStream {
|
||||
fn make_match_arm(
|
||||
spec: &PolymorphicEnumLoopBuildSpec,
|
||||
rule: &PolymorphicEnumLoopRule,
|
||||
) -> TokenStream {
|
||||
match rule {
|
||||
PolymorphicEnumLoopRule::PassThrough(pass_through) => make_pass_through(pass_through),
|
||||
PolymorphicEnumLoopRule::Build(build) => make_build(spec, build),
|
||||
|
||||
Loading…
Reference in New Issue
Block a user