From 8b1887c44033d3d183eea142d52a95e9986ae58b Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 11 Mar 2023 11:35:03 -0800 Subject: [PATCH] Remove unneeded attr_name argument when parsing borrow attr --- serde_derive/src/internals/attr.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/serde_derive/src/internals/attr.rs b/serde_derive/src/internals/attr.rs index de6977f1d..5ff190f02 100644 --- a/serde_derive/src/internals/attr.rs +++ b/serde_derive/src/internals/attr.rs @@ -975,7 +975,7 @@ impl Variant { // Parse `#[serde(borrow = "'a + 'b")]` Meta(NameValue(m)) if m.path == BORROW => match &variant.fields { syn::Fields::Unnamed(fields) if fields.unnamed.len() == 1 => { - if let Ok(lifetimes) = parse_lit_into_lifetimes(cx, BORROW, &m.lit) { + if let Ok(lifetimes) = parse_lit_into_lifetimes(cx, &m.lit) { borrow.set( &m.path, BorrowAttribute { @@ -1283,7 +1283,7 @@ impl Field { // Parse `#[serde(borrow = "'a + 'b")]` Meta(NameValue(m)) if m.path == BORROW => { - if let Ok(lifetimes) = parse_lit_into_lifetimes(cx, BORROW, &m.lit) { + if let Ok(lifetimes) = parse_lit_into_lifetimes(cx, &m.lit) { if let Ok(borrowable) = borrowable_lifetimes(cx, &ident, field) { for lifetime in &lifetimes { if !borrowable.contains(lifetime) { @@ -1628,12 +1628,8 @@ fn parse_lit_into_ty(cx: &Ctxt, attr_name: Symbol, lit: &syn::Lit) -> Result Result, ()> { - let string = get_lit_str(cx, attr_name, lit)?; +fn parse_lit_into_lifetimes(cx: &Ctxt, lit: &syn::Lit) -> Result, ()> { + let string = get_lit_str(cx, BORROW, lit)?; if let Ok(lifetimes) = string.parse_with(|input: ParseStream| { let mut set = BTreeSet::new();