From 9f65977b99de084abaae6d6475367be00ce27435 Mon Sep 17 00:00:00 2001 From: Sergio Benitez Date: Mon, 15 May 2023 16:53:26 -0700 Subject: [PATCH] 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. --- core/codegen/src/derive/form_field.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/core/codegen/src/derive/form_field.rs b/core/codegen/src/derive/form_field.rs index e1723f23..737673d6 100644 --- a/core/codegen/src/derive/form_field.rs +++ b/core/codegen/src/derive/form_field.rs @@ -368,7 +368,8 @@ pub fn validators<'v>(field: Field<'v>) -> Result 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 })