Refer directly to serde_path in Deserialize impl

This makes it not a breaking change if we later want to eliminate
the `use #serde_path as _serde;` line.
This commit is contained in:
David Tolnay 2019-04-03 09:16:17 -07:00
parent b4d8a55b2a
commit 2f1945eaf2
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -27,15 +27,16 @@ pub fn expand_derive_deserialize(input: &syn::DeriveInput) -> Result<TokenStream
let (de_impl_generics, _, ty_generics, where_clause) = split_with_de_lifetime(&params);
let body = Stmts(deserialize_body(&cont, &params));
let delife = params.borrowed.de_lifetime();
let serde = cont.attrs.serde_path();
let impl_block = if let Some(remote) = cont.attrs.remote() {
let vis = &input.vis;
let used = pretend::pretend_used(&cont);
quote! {
impl #de_impl_generics #ident #ty_generics #where_clause {
#vis fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result<#remote #ty_generics, __D::Error>
#vis fn deserialize<__D>(__deserializer: __D) -> #serde::export::Result<#remote #ty_generics, __D::Error>
where
__D: _serde::Deserializer<#delife>,
__D: #serde::Deserializer<#delife>,
{
#used
#body
@ -47,10 +48,10 @@ pub fn expand_derive_deserialize(input: &syn::DeriveInput) -> Result<TokenStream
quote! {
#[automatically_derived]
impl #de_impl_generics _serde::Deserialize<#delife> for #ident #ty_generics #where_clause {
fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result<Self, __D::Error>
impl #de_impl_generics #serde::Deserialize<#delife> for #ident #ty_generics #where_clause {
fn deserialize<__D>(__deserializer: __D) -> #serde::export::Result<Self, __D::Error>
where
__D: _serde::Deserializer<#delife>,
__D: #serde::Deserializer<#delife>,
{
#body
}