Skip to content

Commit

Permalink
clippy: tracing: allow needless_borrow on record
Browse files Browse the repository at this point in the history
tracing-attributes 0.1.23 ships with a smarter `Span::record` that
allows owned values [^1], which makes

This means that previously invalid code such as:

    span.record("num_updates", num_items);

Is now valid, which makes clippy throw a warning for needless_borrow

Fixing the lint, however, means that foca would require a strict version
check for tracing-attributes (otherwise anything pulling 0.1.22 or
bellow would not compile anymore).

I don't want a strict dependency on tracing: it's tangential do foca and
I'd like users to benefit from the improvements that might be shipped
along, so I fix the lint warning by ignoring it instead.

Once we get a (at least minor) version bump on `tracing`, this can be
removed and updated to skip the borrow.

[^1]: tokio-rs/tracing#2212
  • Loading branch information
caio committed Nov 13, 2022
1 parent 202c8c6 commit 52e4e67
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/lib.rs
Expand Up @@ -1152,6 +1152,7 @@ where
// Seek back and write the correct number of items added
buf.get_mut()[tally_position..].as_mut().put_u16(num_items);
#[cfg(feature = "tracing")]
#[allow(clippy::needless_borrow)]
span.record("num_updates", &num_items);
}

Expand All @@ -1168,11 +1169,13 @@ where
#[cfg_attr(not(feature = "tracing"), allow(unused_variables))]
let num_broadcasts = self.custom_broadcasts.fill(&mut buf, usize::MAX);
#[cfg(feature = "tracing")]
#[allow(clippy::needless_borrow)]
span.record("num_broadcasts", &num_broadcasts);
}

let data = buf.into_inner();
#[cfg(feature = "tracing")]
#[allow(clippy::needless_borrow)]
span.record("len", &data.len());

#[cfg(feature = "tracing")]
Expand Down

0 comments on commit 52e4e67

Please sign in to comment.