Skip to content

Commit

Permalink
Remove unneeded attr_name argument when parsing borrow attr
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Mar 11, 2023
1 parent bbfb1d3 commit 8b1887c
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions serde_derive/src/internals/attr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -1628,12 +1628,8 @@ fn parse_lit_into_ty(cx: &Ctxt, attr_name: Symbol, lit: &syn::Lit) -> Result<syn

// Parses a string literal like "'a + 'b + 'c" containing a nonempty list of
// lifetimes separated by `+`.
fn parse_lit_into_lifetimes(
cx: &Ctxt,
attr_name: Symbol,
lit: &syn::Lit,
) -> Result<BTreeSet<syn::Lifetime>, ()> {
let string = get_lit_str(cx, attr_name, lit)?;
fn parse_lit_into_lifetimes(cx: &Ctxt, lit: &syn::Lit) -> Result<BTreeSet<syn::Lifetime>, ()> {
let string = get_lit_str(cx, BORROW, lit)?;

if let Ok(lifetimes) = string.parse_with(|input: ParseStream| {
let mut set = BTreeSet::new();
Expand Down

0 comments on commit 8b1887c

Please sign in to comment.