Remove closure borrow in 'FromForm' derive.

The codegen for field validations previously included a closure that
could potentially partially borrow a 'Copy' field of the context
structure. To prevent this, 'let'-assign the field before the closure is
created, and use the assignment inside of the closure.
This commit is contained in:
Sergio Benitez 2023-05-15 16:53:26 -07:00
parent f1f533c1e5
commit 9f65977b99
1 changed files with 2 additions and 1 deletions

View File

@ -368,7 +368,8 @@ pub fn validators<'v>(field: Field<'v>) -> Result<impl Iterator<Item = syn::Expr
_ => Ok(()),
};
__result.map_err(|__e| match #name_opt {
let __e_name = #name_opt;
__result.map_err(|__e| match __e_name {
Some(__name) => __e.with_name(__name),
None => __e
})