From 7a2b1379122ef7daf8fb9e6444d4fe49f3f91e00 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 7 Sep 2019 20:24:53 -0700 Subject: [PATCH] Reuse span in default deserialize_with path for Cows --- serde_derive/src/internals/attr.rs | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/serde_derive/src/internals/attr.rs b/serde_derive/src/internals/attr.rs index 22badfca..b21ade38 100644 --- a/serde_derive/src/internals/attr.rs +++ b/serde_derive/src/internals/attr.rs @@ -1431,14 +1431,12 @@ impl Field { leading_colon: None, segments: Punctuated::new(), }; + let span = Span::call_site(); + path.segments.push(Ident::new("_serde", span).into()); + path.segments.push(Ident::new("private", span).into()); + path.segments.push(Ident::new("de", span).into()); path.segments - .push(Ident::new("_serde", Span::call_site()).into()); - path.segments - .push(Ident::new("private", Span::call_site()).into()); - path.segments - .push(Ident::new("de", Span::call_site()).into()); - path.segments - .push(Ident::new("borrow_cow_str", Span::call_site()).into()); + .push(Ident::new("borrow_cow_str", span).into()); let expr = syn::ExprPath { attrs: Vec::new(), qself: None, @@ -1450,14 +1448,12 @@ impl Field { leading_colon: None, segments: Punctuated::new(), }; + let span = Span::call_site(); + path.segments.push(Ident::new("_serde", span).into()); + path.segments.push(Ident::new("private", span).into()); + path.segments.push(Ident::new("de", span).into()); path.segments - .push(Ident::new("_serde", Span::call_site()).into()); - path.segments - .push(Ident::new("private", Span::call_site()).into()); - path.segments - .push(Ident::new("de", Span::call_site()).into()); - path.segments - .push(Ident::new("borrow_cow_bytes", Span::call_site()).into()); + .push(Ident::new("borrow_cow_bytes", span).into()); let expr = syn::ExprPath { attrs: Vec::new(), qself: None,