Fix 'clippy::needless_late_init' in form codegen.

Changes codegen for '#[field(default = e)]' to resolve the
'needless_late_init' Clippy warning.
This commit is contained in:
Konrad Borowski 2022-05-11 19:29:32 +02:00 committed by Sergio Benitez
parent 1587c501f3
commit 6f223518e4
1 changed files with 4 additions and 5 deletions

View File

@ -392,12 +392,11 @@ pub fn default<'v>(field: Field<'v>) -> Result<Option<TokenStream>> {
},
(Some(e), None) | (None, Some(e)) => {
Ok(Some(quote_spanned!(e.span() => {
let __default: Option<#ty>;
if __opts.strict {
__default = None;
let __default: Option<#ty> = if __opts.strict {
None
} else {
__default = #e;
}
#e
};
__default
})))