Inline visitor_expr of unit struct deserialize impl

This commit is contained in:
David Tolnay 2023-07-09 18:03:58 -07:00
parent 662fc3861c
commit f75426f47e
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -417,13 +417,6 @@ fn deserialize_unit_struct(params: &Parameters, cattrs: &attr::Container) -> Fra
let expecting = format!("unit struct {}", params.type_name());
let expecting = cattrs.expecting().unwrap_or(&expecting);
let visitor_expr = quote! {
__Visitor {
marker: _serde::__private::PhantomData::<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData,
}
};
quote_block! {
#[doc(hidden)]
struct __Visitor #de_impl_generics #where_clause {
@ -447,7 +440,14 @@ fn deserialize_unit_struct(params: &Parameters, cattrs: &attr::Container) -> Fra
}
}
_serde::Deserializer::deserialize_unit_struct(__deserializer, #type_name, #visitor_expr)
_serde::Deserializer::deserialize_unit_struct(
__deserializer,
#type_name,
__Visitor {
marker: _serde::__private::PhantomData::<#this_type #ty_generics>,
lifetime: _serde::__private::PhantomData,
},
)
}
}