mirror of https://github.com/rwf2/Rocket.git
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.
This commit is contained in:
parent
ac3efbc892
commit
9063cf0ac2
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue