Skip to content

Commit

Permalink
Merge pull request #1161 from zeenix/clippy-fixes
Browse files Browse the repository at this point in the history
🚨 zb,zn,zv: Satisfy latest clippy
  • Loading branch information
zeenix authored Nov 28, 2024
2 parents 7f037ba + 5eb5d8f commit eaef2fd
Show file tree
Hide file tree
Showing 29 changed files with 93 additions and 92 deletions.
4 changes: 2 additions & 2 deletions zbus/benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ impl<'s> BigBoy<'s> {
}

fn address_parse(c: &mut Criterion) {
const UNIX_ADDRESS: &'static str = "unix:path=/tmp/dbus/long/loooooooong/path/to/socket\
const UNIX_ADDRESS: &str = "unix:path=/tmp/dbus/long/loooooooong/path/to/socket\
/so/we/need/to/keeeeeeeeeep/going/where/no/man/has/gone/before,runtime=yes,\
guid=0123456789ABCDEF0123456789ABCDEF";
const TCP_ADDRESS: &'static str = "tcp:host=some.looong.name.so.we.must.keep.going.on.and.on.\
const TCP_ADDRESS: &str = "tcp:host=some.looong.name.so.we.must.keep.going.on.and.on.\
on,port=1234,family=ipv4,guid=0123456789ABCDEF0123456789ABCDEF";

let mut group = c.benchmark_group("parse_dbus_address");
Expand Down
2 changes: 1 addition & 1 deletion zbus/src/blocking/proxy/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ impl<'a, T> Builder<'a, T> {
}
}

impl<'a, T> Builder<'a, T>
impl<T> Builder<'_, T>
where
T: Defaults,
{
Expand Down
6 changes: 3 additions & 3 deletions zbus/src/blocking/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ where
pub struct PropertyChanged<'a, T>(crate::proxy::PropertyChanged<'a, T>);

// split this out to avoid the trait bound on `name` method
impl<'a, T> PropertyChanged<'a, T> {
impl<T> PropertyChanged<'_, T> {
/// Get the name of the property that changed.
pub fn name(&self) -> &str {
self.0.name()
Expand All @@ -465,7 +465,7 @@ impl<'a, T> PropertyChanged<'a, T> {
}
}

impl<'a, T> PropertyChanged<'a, T>
impl<T> PropertyChanged<'_, T>
where
T: TryFrom<zvariant::OwnedValue>,
T::Error: Into<crate::Error>,
Expand All @@ -492,7 +492,7 @@ impl<'a> OwnerChangedIterator<'a> {
}
}

impl<'a> std::iter::Iterator for OwnerChangedIterator<'a> {
impl std::iter::Iterator for OwnerChangedIterator<'_> {
type Item = Option<UniqueName<'static>>;

fn next(&mut self) -> Option<Self::Item> {
Expand Down
2 changes: 1 addition & 1 deletion zbus/src/match_rule/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,7 @@ pub enum PathSpec<'m> {

assert_impl_all!(PathSpec<'_>: Send, Sync, Unpin);

impl<'m> PathSpec<'m> {
impl PathSpec<'_> {
/// Create an owned clone of `self`.
fn to_owned(&self) -> PathSpec<'static> {
match self {
Expand Down
4 changes: 2 additions & 2 deletions zbus/src/message/fields.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Fields<'_> {
}
}

impl<'f> Serialize for Fields<'f> {
impl Serialize for Fields<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down Expand Up @@ -82,7 +82,7 @@ impl<'f> Serialize for Fields<'f> {
#[zvariant(signature = "v")]
struct SignatureSerializer<'a>(&'a Signature);

impl<'a> Serialize for SignatureSerializer<'a> {
impl Serialize for SignatureSerializer<'_> {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
4 changes: 2 additions & 2 deletions zbus/src/proxy/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct Builder<'a, T = ()> {
uncached_properties: Option<HashSet<Str<'a>>>,
}

impl<'a, T> Clone for Builder<'a, T> {
impl<T> Clone for Builder<'_, T> {
fn clone(&self) -> Self {
Self {
conn: self.conn.clone(),
Expand Down Expand Up @@ -142,7 +142,7 @@ impl<'a, T> Builder<'a, T> {
}
}

impl<'a, T> Builder<'a, T>
impl<T> Builder<'_, T>
where
T: super::Defaults,
{
Expand Down
10 changes: 5 additions & 5 deletions zbus/src/proxy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ impl<'a, T> PropertyChanged<'a, T> {
values: RwLockReadGuard<'w, HashMap<String, PropertyValue>>,
}

impl<'w> Deref for Wrapper<'w> {
impl Deref for Wrapper<'_> {
type Target = Value<'static>;

fn deref(&self) -> &Self::Target {
Expand Down Expand Up @@ -1096,7 +1096,7 @@ impl<'a> OwnerChangedStream<'a> {
}
}

impl<'a> stream::Stream for OwnerChangedStream<'a> {
impl stream::Stream for OwnerChangedStream<'_> {
type Item = Option<UniqueName<'static>>;

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
Expand Down Expand Up @@ -1276,15 +1276,15 @@ impl<'a> SignalStream<'a> {

assert_impl_all!(SignalStream<'_>: Send, Sync, Unpin);

impl<'a> stream::Stream for SignalStream<'a> {
impl stream::Stream for SignalStream<'_> {
type Item = Message;

fn poll_next(self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Option<Self::Item>> {
OrderedStream::poll_next_before(self, cx, None).map(|res| res.into_data())
}
}

impl<'a> OrderedStream for SignalStream<'a> {
impl OrderedStream for SignalStream<'_> {
type Data = Message;
type Ordering = Sequence;

Expand Down Expand Up @@ -1317,7 +1317,7 @@ impl<'a> OrderedStream for SignalStream<'a> {
}
}

impl<'a> stream::FusedStream for SignalStream<'a> {
impl stream::FusedStream for SignalStream<'_> {
fn is_terminated(&self) -> bool {
ordered_stream::FusedOrderedStream::is_terminated(&self.stream)
}
Expand Down
2 changes: 1 addition & 1 deletion zbus/tests/issue/issue_173.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ fn issue_173() {

// We receive two signals, each time from different unique names. W/o the fix for
// issue#173, the second iteration hangs.
while let Some(_) = signals.next().await {
while signals.next().await.is_some() {
tx.broadcast_direct(()).await.unwrap();
}
})
Expand Down
2 changes: 1 addition & 1 deletion zbus_macros/src/iface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ struct Property<'a> {
doc_comments: TokenStream,
}

impl<'a> Property<'a> {
impl Property<'_> {
fn new() -> Self {
Self {
read: false,
Expand Down
8 changes: 4 additions & 4 deletions zbus_names/benches/benchmarks.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};

fn name_parse(c: &mut Criterion) {
const WELL_KNOWN_NAME: &'static str = "a.very.loooooooooooooooooo-ooooooo_0000o0ng.Name.\
const WELL_KNOWN_NAME: &str = "a.very.loooooooooooooooooo-ooooooo_0000o0ng.Name.\
That.Is.Valid.For.DBus.and_good.For.benchmarks.I-guess";
const UNIQUE_NAME: &'static str = ":a.very.loooooooooooooooooo-ooooooo_0000o0ng.Name.\
const UNIQUE_NAME: &str = ":a.very.loooooooooooooooooo-ooooooo_0000o0ng.Name.\
That.Is.Valid.For.DBus.and_good.For.benchmarks.I-guess";
const INTERFACE_NAME: &'static str = "a.very.loooooooooooooooooo_ooooooo_0000o0ng.Name.\
const INTERFACE_NAME: &str = "a.very.loooooooooooooooooo_ooooooo_0000o0ng.Name.\
That.Is.Valid.For.DBus.and_good.For.benchmarks.I_guess";
const MEMBER_NAME: &'static str = "a_very_loooooooooooooooooo_ooooooo_0000o0ng_Name_\
const MEMBER_NAME: &str = "a_very_loooooooooooooooooo_ooooooo_0000o0ng_Name_\
That_Is_Valid_For_DBus_and_good_For_benchmarks_I_guess";

let mut group = c.benchmark_group("parse_name");
Expand Down
6 changes: 3 additions & 3 deletions zbus_names/src/bus_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ assert_impl_all!(BusName<'_>: Send, Sync, Unpin);

impl_str_basic!(BusName<'_>);

impl<'name> BusName<'name> {
impl BusName<'_> {
/// This is faster than `Clone::clone` when `self` contains owned data.
pub fn as_ref(&self) -> BusName<'_> {
match self {
Expand Down Expand Up @@ -260,15 +260,15 @@ impl<'s> TryFrom<&'s str> for BusName<'s> {
}
}

impl<'s> TryFrom<String> for BusName<'s> {
impl TryFrom<String> for BusName<'_> {
type Error = Error;

fn try_from(value: String) -> Result<Self> {
Str::from(value).try_into()
}
}

impl<'s> TryFrom<Arc<str>> for BusName<'s> {
impl TryFrom<Arc<str>> for BusName<'_> {
type Error = Error;

fn try_from(value: Arc<str>) -> Result<Self> {
Expand Down
4 changes: 2 additions & 2 deletions zbus_names/src/well_known_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,13 @@ impl Display for WellKnownName<'_> {
}
}

impl<'a> PartialEq<str> for WellKnownName<'a> {
impl PartialEq<str> for WellKnownName<'_> {
fn eq(&self, other: &str) -> bool {
self.as_str() == other
}
}

impl<'a> PartialEq<&str> for WellKnownName<'a> {
impl PartialEq<&str> for WellKnownName<'_> {
fn eq(&self, other: &&str) -> bool {
self.as_str() == *other
}
Expand Down
6 changes: 3 additions & 3 deletions zbus_xml/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ pub struct Method<'a> {

assert_impl_all!(Method<'_>: Send, Sync, Unpin);

impl<'a> Method<'a> {
impl Method<'_> {
/// Return the method name.
pub fn name(&self) -> MemberName<'_> {
self.name.as_ref()
Expand Down Expand Up @@ -137,7 +137,7 @@ pub struct Signal<'a> {

assert_impl_all!(Signal<'_>: Send, Sync, Unpin);

impl<'a> Signal<'a> {
impl Signal<'_> {
/// Return the signal name.
pub fn name(&self) -> MemberName<'_> {
self.name.as_ref()
Expand Down Expand Up @@ -192,7 +192,7 @@ pub struct Property<'a> {

assert_impl_all!(Property<'_>: Send, Sync, Unpin);

impl<'a> Property<'a> {
impl Property<'_> {
/// Returns the property name.
pub fn name(&self) -> PropertyName<'_> {
self.name.as_ref()
Expand Down
4 changes: 2 additions & 2 deletions zbus_xmlgen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ pub struct GenTrait<'i> {
pub format: bool,
}

impl<'i> Display for GenTrait<'i> {
impl Display for GenTrait<'_> {
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
if self.format {
let mut unformatted = String::new();
Expand All @@ -152,7 +152,7 @@ impl<'i> Display for GenTrait<'i> {
}
}

impl<'i> GenTrait<'i> {
impl GenTrait<'_> {
fn write_interface<W: Write>(&self, w: &mut W) -> std::fmt::Result {
let iface = self.interface;
let idx = iface.name().rfind('.').unwrap() + 1;
Expand Down
2 changes: 1 addition & 1 deletion zbus_xmlgen/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ struct DBusInfo<'a>(
String,
);

impl<'a> DBusInfo<'a> {
impl DBusInfo<'_> {
fn new(
connection: Connection,
service: String,
Expand Down
2 changes: 1 addition & 1 deletion zvariant/benches/benchmarks.rs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ fn signature_parse(c: &mut Criterion) {
}

fn object_path_parse(c: &mut Criterion) {
const PATH: &'static str = "/a/very/very_very/veeeeeeeeeeeeeery/long/long_long/long/long/\
const PATH: &str = "/a/very/very_very/veeeeeeeeeeeeeery/long/long_long/long/long/\
_/long_path/to_test_parsing_of/paths/you/see";

c.bench_function("object_path_parse", |b| {
Expand Down
4 changes: 2 additions & 2 deletions zvariant/src/array.rs
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ impl ArraySeed {

assert_impl_all!(ArraySeed: Unpin);

impl<'a> DynamicType for Array<'a> {
impl DynamicType for Array<'_> {
fn signature(&self) -> Signature {
self.signature.clone()
}
Expand Down Expand Up @@ -311,7 +311,7 @@ where
// TODO: this could be useful
// impl<'a, 'b, T> TryFrom<&'a Array<'b>> for Vec<T>

impl<'a> Serialize for Array<'a> {
impl Serialize for Array<'_> {
fn serialize<S>(&self, serializer: S) -> core::result::Result<S::Ok, S::Error>
where
S: Serializer,
Expand Down
25 changes: 13 additions & 12 deletions zvariant/src/dbus/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::{
#[derive(Debug)]
pub(crate) struct Deserializer<'de, 'sig, 'f, F>(pub(crate) DeserializerCommon<'de, 'sig, 'f, F>);

#[allow(clippy::needless_lifetimes)]
impl<'de, 'sig, 'f, F> Deserializer<'de, 'sig, 'f, F> {
/// Create a Deserializer struct instance.
///
Expand Down Expand Up @@ -74,8 +75,8 @@ macro_rules! deserialize_as {
}
}

impl<'de, 'd, 'sig, 'f, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> de::Deserializer<'de>
for &'d mut Deserializer<'de, 'sig, 'f, F>
impl<'de, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> de::Deserializer<'de>
for &mut Deserializer<'de, '_, '_, F>
{
type Error = Error;

Expand Down Expand Up @@ -481,8 +482,8 @@ fn deserialize_ay<'de, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F>(

struct ArraySeqDeserializer<'d, 'de, 'sig, 'f, F>(ArrayDeserializer<'d, 'de, 'sig, 'f, F>);

impl<'d, 'de, 'sig, 'f, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> SeqAccess<'de>
for ArraySeqDeserializer<'d, 'de, 'sig, 'f, F>
impl<'de, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> SeqAccess<'de>
for ArraySeqDeserializer<'_, 'de, '_, '_, F>
{
type Error = Error;

Expand Down Expand Up @@ -522,8 +523,8 @@ impl<'d, 'de, 'sig, 'f, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F>
}
}

impl<'d, 'de, 'sig, 'f, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> MapAccess<'de>
for ArrayMapDeserializer<'d, 'de, 'sig, 'f, F>
impl<'de, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> MapAccess<'de>
for ArrayMapDeserializer<'_, 'de, '_, '_, F>
{
type Error = Error;

Expand Down Expand Up @@ -574,8 +575,8 @@ impl<'d, 'de, 'sig, 'f, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F>
}
}

impl<'d, 'de, 'sig, 'f, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> SeqAccess<'de>
for StructureDeserializer<'d, 'de, 'sig, 'f, F>
impl<'de, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> SeqAccess<'de>
for StructureDeserializer<'_, 'de, '_, '_, F>
{
type Error = Error;

Expand Down Expand Up @@ -640,8 +641,8 @@ impl<'d, 'de, 'sig, 'f, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F>
}
}

impl<'d, 'de, 'sig, 'f, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> SeqAccess<'de>
for ValueDeserializer<'d, 'de, 'sig, 'f, F>
impl<'de, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> SeqAccess<'de>
for ValueDeserializer<'_, 'de, '_, '_, F>
{
type Error = Error;

Expand Down Expand Up @@ -692,8 +693,8 @@ impl<'d, 'de, 'sig, 'f, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> SeqAccess<'de
}
}

impl<'de, 'd, 'sig, 'f, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> EnumAccess<'de>
for crate::de::Enum<&'d mut Deserializer<'de, 'sig, 'f, F>, F>
impl<'de, #[cfg(unix)] F: AsFd, #[cfg(not(unix))] F> EnumAccess<'de>
for crate::de::Enum<&mut Deserializer<'de, '_, '_, F>, F>
{
type Error = Error;
type Variant = Self;
Expand Down
6 changes: 3 additions & 3 deletions zvariant/src/dbus/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ pub struct SeqSerializer<'ser, 'b, W> {
array_signature: &'ser Signature,
}

impl<'ser, 'b, W> SeqSerializer<'ser, 'b, W>
impl<W> SeqSerializer<'_, '_, W>
where
W: Write + Seek,
{
Expand Down Expand Up @@ -401,7 +401,7 @@ where
}
}

impl<'ser, 'b, W> ser::SerializeSeq for SeqSerializer<'ser, 'b, W>
impl<W> ser::SerializeSeq for SeqSerializer<'_, '_, W>
where
W: Write + Seek,
{
Expand Down Expand Up @@ -613,7 +613,7 @@ pub(crate) struct MapSerializer<'ser, 'b, W> {
value_signature: &'ser Signature,
}

impl<'ser, 'b, W> ser::SerializeMap for MapSerializer<'ser, 'b, W>
impl<W> ser::SerializeMap for MapSerializer<'_, '_, W>
where
W: Write + Seek,
{
Expand Down
Loading

0 comments on commit eaef2fd

Please sign in to comment.