From 9063cf0ac2209107c2b387cd9b9faa56404eb38d Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Sat, 26 Jun 2021 12:00:05 -0700 Subject: [PATCH] Visiting internal nodes in form field validator. Previously, recursion into rewriting 'self' in field validations would cease after the first function call. This meant that internal uses of 'self' were not properly rewritten. This commit ameliorates the situation. --- core/codegen/src/derive/form_field.rs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/core/codegen/src/derive/form_field.rs b/core/codegen/src/derive/form_field.rs index 6e9fb1f1..004d86ee 100644 --- a/core/codegen/src/derive/form_field.rs +++ b/core/codegen/src/derive/form_field.rs @@ -243,11 +243,12 @@ impl ValidationMutator<'_> { impl VisitMut for ValidationMutator<'_> { fn visit_expr_call_mut(&mut self, call: &mut syn::ExprCall) { - syn::visit_mut::visit_expr_call_mut(self, call); - // Only modify the first call we see. - if self.visited { return; } + if self.visited { + return syn::visit_mut::visit_expr_call_mut(self, call); + } + self.visited = true; let (parent, field) = (self.parent, self.field); let form_field = match self.local { true => syn::parse2(quote_spanned!(field.span() => &#field)).unwrap(), @@ -258,7 +259,7 @@ impl VisitMut for ValidationMutator<'_> { }; call.args.insert(0, form_field); - self.visited = true; + syn::visit_mut::visit_expr_call_mut(self, call); } fn visit_ident_mut(&mut self, i: &mut syn::Ident) {