Skip to content

Commit

Permalink
Remove closure borrow in 'FromForm' derive.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SergioBenitez committed May 15, 2023
1 parent be49668 commit 1ceb264
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion core/codegen/src/derive/form_field.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down

0 comments on commit 1ceb264

Please sign in to comment.