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::deserialize::util::{make_build_fn_name, make_build_pair}; | ||||||
| use crate::spec::polymorphic_enum_loop_spec::{ | use crate::spec::polymorphic_enum_loop_spec::{ | ||||||
|     PolymorphicEnumLoopBuildSpec, PolymorphicEnumLoopRule, |     PolymorphicEnumLoopBuildSpec, PolymorphicEnumLoopRule, PolymorphicEnumLoopRuleBuild, | ||||||
|     PolymorphicEnumLoopRuleBuild, PolymorphicEnumLoopRuleBuildChild, |     PolymorphicEnumLoopRuleBuildChild, PolymorphicEnumLoopRuleChildOnEach, | ||||||
|     PolymorphicEnumLoopRuleChildOnEach, PolymorphicEnumLoopRulePassThrough, |     PolymorphicEnumLoopRulePassThrough, | ||||||
| }; | }; | ||||||
| use proc_macro2::TokenStream; | use proc_macro2::TokenStream; | ||||||
| use quote::{format_ident, quote}; | 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 { | fn make_on_each_child_build(child: &PolymorphicEnumLoopRuleChildOnEach) -> TokenStream { | ||||||
|     let child_build_fn_ident = format_ident!("{}", make_build_fn_name(child.rule())); |     let child_build_fn_ident = format_ident!("{}", make_build_fn_name(child.rule())); | ||||||
|     quote! { |     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, |             PolymorphicEnumLoopRuleBuildChild::OnEach(_) => true, | ||||||
|             _ => false, |             _ => false, | ||||||
|         }) |         }) | ||||||
|         .map(|child| { |         .map(|child| match child { | ||||||
|             match child { |  | ||||||
|             PolymorphicEnumLoopRuleBuildChild::OnEach(on_each) => on_each, |             PolymorphicEnumLoopRuleBuildChild::OnEach(on_each) => on_each, | ||||||
|             _ => unreachable!(), |             _ => unreachable!(), | ||||||
|             } |  | ||||||
|         }) |         }) | ||||||
|         .unwrap(); |         .unwrap(); | ||||||
| 
 | 
 | ||||||
| @ -53,7 +51,7 @@ fn make_build( | |||||||
|         .children() |         .children() | ||||||
|         .map(|child| match child { |         .map(|child| match child { | ||||||
|             PolymorphicEnumLoopRuleBuildChild::UseCurrent(_) => { |             PolymorphicEnumLoopRuleBuildChild::UseCurrent(_) => { | ||||||
|                 quote! { result.unwrap() } |                 quote! { Box::new(result.unwrap()) } | ||||||
|             } |             } | ||||||
|             PolymorphicEnumLoopRuleBuildChild::OnEach(_) => quote! { on_each_child }, |             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 { |     match rule { | ||||||
|         PolymorphicEnumLoopRule::PassThrough(pass_through) => make_pass_through(pass_through), |         PolymorphicEnumLoopRule::PassThrough(pass_through) => make_pass_through(pass_through), | ||||||
|         PolymorphicEnumLoopRule::Build(build) => make_build(spec, build), |         PolymorphicEnumLoopRule::Build(build) => make_build(spec, build), | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 Jesse Brault
						Jesse Brault