Remove unneeded quote_spanned that uses call_site

This commit is contained in:
David Tolnay 2018-04-21 11:32:57 -07:00
parent 5f8fa33756
commit b37cf858ce
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 14 additions and 18 deletions

View File

@ -37,10 +37,9 @@ pub fn expand_derive_deserialize(input: &syn::DeriveInput) -> Result<Tokens, Str
let impl_block = if let Some(remote) = cont.attrs.remote() { let impl_block = if let Some(remote) = cont.attrs.remote() {
let vis = &input.vis; let vis = &input.vis;
let fun = quote_spanned!(Span::call_site()=> deserialize);
quote! { quote! {
impl #de_impl_generics #ident #ty_generics #where_clause { impl #de_impl_generics #ident #ty_generics #where_clause {
#vis fn #fun<__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> where __D: _serde::Deserializer<#delife>
{ {
#body #body
@ -586,11 +585,11 @@ fn deserialize_seq(
let mut result = if is_struct { let mut result = if is_struct {
let names = fields.iter().map(|f| &f.ident); let names = fields.iter().map(|f| &f.ident);
quote_spanned! {Span::call_site()=> quote! {
#type_path { #( #names: #vars ),* } #type_path { #( #names: #vars ),* }
} }
} else { } else {
quote_spanned! {Span::call_site()=> quote! {
#type_path ( #(#vars),* ) #type_path ( #(#vars),* )
} }
}; };
@ -652,11 +651,10 @@ fn deserialize_seq_in_place(
}) })
}); });
let dot = quote_spanned!(Span::call_site()=> .);
if field.attrs.skip_deserializing() { if field.attrs.skip_deserializing() {
let default = Expr(expr_is_missing(field, cattrs)); let default = Expr(expr_is_missing(field, cattrs));
quote! { quote! {
self.place #dot #field_name = #default; self.place.#field_name = #default;
} }
} else { } else {
let return_invalid_length = quote! { let return_invalid_length = quote! {
@ -666,7 +664,7 @@ fn deserialize_seq_in_place(
None => { None => {
quote! { quote! {
if let _serde::export::None = try!(_serde::de::SeqAccess::next_element_seed(&mut __seq, if let _serde::export::None = try!(_serde::de::SeqAccess::next_element_seed(&mut __seq,
_serde::private::de::InPlaceSeed(&mut self.place #dot #field_name))) _serde::private::de::InPlaceSeed(&mut self.place.#field_name)))
{ {
#return_invalid_length #return_invalid_length
} }
@ -679,7 +677,7 @@ fn deserialize_seq_in_place(
#wrapper #wrapper
match try!(_serde::de::SeqAccess::next_element::<#wrapper_ty>(&mut __seq)) { match try!(_serde::de::SeqAccess::next_element::<#wrapper_ty>(&mut __seq)) {
_serde::export::Some(__wrap) => { _serde::export::Some(__wrap) => {
self.place #dot #field_name = __wrap.value; self.place.#field_name = __wrap.value;
} }
_serde::export::None => { _serde::export::None => {
#return_invalid_length #return_invalid_length
@ -735,7 +733,7 @@ fn deserialize_newtype_struct(type_path: &Tokens, params: &Parameters, field: &F
} }
}; };
let mut result = quote_spanned!(Span::call_site()=> #type_path(__field0)); let mut result = quote!(#type_path(__field0));
if params.has_getter { if params.has_getter {
let this = &params.this; let this = &params.this;
result = quote! { result = quote! {
@ -761,13 +759,12 @@ fn deserialize_newtype_struct_in_place(params: &Parameters, field: &Field) -> To
let delife = params.borrowed.de_lifetime(); let delife = params.borrowed.de_lifetime();
let elem = quote_spanned!(Span::call_site()=> .0);
quote! { quote! {
#[inline] #[inline]
fn visit_newtype_struct<__E>(self, __e: __E) -> _serde::export::Result<Self::Value, __E::Error> fn visit_newtype_struct<__E>(self, __e: __E) -> _serde::export::Result<Self::Value, __E::Error>
where __E: _serde::Deserializer<#delife> where __E: _serde::Deserializer<#delife>
{ {
_serde::Deserialize::deserialize_in_place(__e, &mut self.place #elem) _serde::Deserialize::deserialize_in_place(__e, &mut self.place.0)
} }
} }
} }
@ -2309,9 +2306,9 @@ fn deserialize_map(
let ident = field.ident.expect("struct contains unnamed fields"); let ident = field.ident.expect("struct contains unnamed fields");
if field.attrs.skip_deserializing() { if field.attrs.skip_deserializing() {
let value = Expr(expr_is_missing(field, cattrs)); let value = Expr(expr_is_missing(field, cattrs));
quote_spanned!(Span::call_site()=> #ident: #value) quote!(#ident: #value)
} else { } else {
quote_spanned!(Span::call_site()=> #ident: #name) quote!(#ident: #name)
} }
}); });
@ -2329,7 +2326,7 @@ fn deserialize_map(
} }
}; };
let mut result = quote_spanned!(Span::call_site()=> #struct_path { #(#result),* }); let mut result = quote!(#struct_path { #(#result),* });
if params.has_getter { if params.has_getter {
let this = &params.this; let this = &params.this;
result = quote! { result = quote! {

View File

@ -33,10 +33,9 @@ pub fn expand_derive_serialize(input: &syn::DeriveInput) -> Result<Tokens, Strin
let impl_block = if let Some(remote) = cont.attrs.remote() { let impl_block = if let Some(remote) = cont.attrs.remote() {
let vis = &input.vis; let vis = &input.vis;
let fun = quote_spanned!(Span::call_site()=> serialize);
quote! { quote! {
impl #impl_generics #ident #ty_generics #where_clause { impl #impl_generics #ident #ty_generics #where_clause {
#vis fn #fun<__S>(__self: &#remote #ty_generics, __serializer: __S) -> _serde::export::Result<__S::Ok, __S::Error> #vis fn serialize<__S>(__self: &#remote #ty_generics, __serializer: __S) -> _serde::export::Result<__S::Ok, __S::Error>
where __S: _serde::Serializer where __S: _serde::Serializer
{ {
#body #body
@ -1059,9 +1058,9 @@ fn mut_if(is_mut: bool) -> Option<Tokens> {
fn get_member(params: &Parameters, field: &Field, member: &Member) -> Tokens { fn get_member(params: &Parameters, field: &Field, member: &Member) -> Tokens {
let self_var = &params.self_var; let self_var = &params.self_var;
match (params.is_remote, field.attrs.getter()) { match (params.is_remote, field.attrs.getter()) {
(false, None) => quote_spanned!(Span::call_site()=> &#self_var.#member), (false, None) => quote!(&#self_var.#member),
(true, None) => { (true, None) => {
let inner = quote_spanned!(Span::call_site()=> &#self_var.#member); let inner = quote!(&#self_var.#member);
let ty = field.ty; let ty = field.ty;
quote!(_serde::private::ser::constrain::<#ty>(#inner)) quote!(_serde::private::ser::constrain::<#ty>(#inner))
} }