Skip to content

Commit 02563f5

Browse files
authored
Merge pull request #1416 from dbus2/clippy-fixes
🚨 all: Fix against latest clippy
2 parents 7c749b5 + 9d02b5d commit 02563f5

File tree

16 files changed

+48
-57
lines changed

16 files changed

+48
-57
lines changed

zbus/examples/screen-brightness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn main() {
1616
} else if s == "-" {
1717
"StepDown"
1818
} else {
19-
panic!("Expected either '+' or '-' argument. Got: {}", s);
19+
panic!("Expected either '+' or '-' argument. Got: {s}");
2020
}
2121
}
2222
None => "StepUp",

zbus/src/address/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ impl Display for Address {
114114
self.transport.fmt(f)?;
115115

116116
if let Some(guid) = &self.guid {
117-
write!(f, ",guid={}", guid)?;
117+
write!(f, ",guid={guid}")?;
118118
}
119119

120120
Ok(())

zbus/src/address/transport/autolaunch.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ impl std::fmt::Display for Autolaunch {
1111
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
1212
write!(f, "autolaunch:")?;
1313
if let Some(scope) = &self.scope {
14-
write!(f, "scope={}", scope)?;
14+
write!(f, "scope={scope}")?;
1515
}
1616

1717
Ok(())

zbus/src/address/transport/launchd.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl Launchd {
3636
}
3737

3838
let addr = String::from_utf8(output.stdout).map_err(|e| {
39-
crate::Error::Address(format!("Unable to parse launchctl output as UTF-8: {}", e))
39+
crate::Error::Address(format!("Unable to parse launchctl output as UTF-8: {e}"))
4040
})?;
4141

4242
Ok(Transport::Unix(Unix::new(UnixSocket::File(

zbus/src/address/transport/mod.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -351,19 +351,19 @@ pub(super) fn encode_percents(f: &mut Formatter<'_>, mut value: &[u8]) -> std::f
351351
impl Display for Transport {
352352
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
353353
match self {
354-
Self::Tcp(tcp) => write!(f, "{}", tcp)?,
355-
Self::Unix(unix) => write!(f, "{}", unix)?,
354+
Self::Tcp(tcp) => write!(f, "{tcp}")?,
355+
Self::Unix(unix) => write!(f, "{unix}")?,
356356
#[cfg(unix)]
357-
Self::Unixexec(unixexec) => write!(f, "{}", unixexec)?,
357+
Self::Unixexec(unixexec) => write!(f, "{unixexec}")?,
358358
#[cfg(any(
359359
all(feature = "vsock", not(feature = "tokio")),
360360
feature = "tokio-vsock"
361361
))]
362362
Self::Vsock(vsock) => write!(f, "{}", vsock)?,
363363
#[cfg(windows)]
364-
Self::Autolaunch(autolaunch) => write!(f, "{}", autolaunch)?,
364+
Self::Autolaunch(autolaunch) => write!(f, "{autolaunch}")?,
365365
#[cfg(target_os = "macos")]
366-
Self::Launchd(launchd) => write!(f, "{}", launchd)?,
366+
Self::Launchd(launchd) => write!(f, "{launchd}")?,
367367
}
368368

369369
Ok(())

zbus/src/connection/handshake/client.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl Client {
5858
let write = self.common.socket_mut().write_mut();
5959

6060
let written = match write.send_zero_byte().await.map_err(|e| {
61-
Error::Handshake(format!("Could not send zero byte with credentials: {}", e))
61+
Error::Handshake(format!("Could not send zero byte with credentials: {e}"))
6262
})? {
6363
// This likely means that the socket type is unable to send SCM_CREDS.
6464
// Let's try to send the 0 byte as a regular message.

zbus/src/error.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl fmt::Display for Error {
145145
Error::InvalidMatchRule => write!(f, "Invalid match rule string"),
146146
Error::Failure(e) => write!(f, "{e}"),
147147
Error::MissingParameter(p) => {
148-
write!(f, "Parameter `{}` was not specified but it is required", p)
148+
write!(f, "Parameter `{p}` was not specified but it is required")
149149
}
150150
Error::InvalidSerial => write!(f, "Serial number in the message header is 0"),
151151
Error::InterfaceExists(i, p) => write!(f, "Interface `{i}` already exists at `{p}`"),

zbus/src/win32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl Mutex {
5454
pub fn lock(&self) -> MutexGuard<'_> {
5555
match unsafe { WaitForSingleObject(self.0.as_raw_handle(), INFINITE) } {
5656
WAIT_ABANDONED | WAIT_OBJECT_0 => MutexGuard(self),
57-
err => panic!("WaitForSingleObject() failed: return code {}", err),
57+
err => panic!("WaitForSingleObject() failed: return code {err}"),
5858
}
5959
}
6060
}
@@ -311,7 +311,7 @@ pub fn autolaunch_bus_address() -> Result<Address, crate::Error> {
311311

312312
let addr = read_shm("DBusDaemonAddressInfo")?;
313313
let addr = String::from_utf8(addr)
314-
.map_err(|e| crate::Error::Address(format!("Unable to parse address as UTF-8: {}", e)))?;
314+
.map_err(|e| crate::Error::Address(format!("Unable to parse address as UTF-8: {e}")))?;
315315

316316
addr.parse()
317317
}

zbus_macros/src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ impl Display for PropertyEmitsChangedSignal {
7474
PropertyEmitsChangedSignal::False => "false",
7575
PropertyEmitsChangedSignal::Invalidates => "invalidates",
7676
};
77-
write!(f, "{}", emits_changed_signal)
77+
write!(f, "{emits_changed_signal}")
7878
}
7979
}
8080

zbus_xmlgen/src/lib.rs

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,13 @@ pub fn write_interfaces(
3939
format: false,
4040
};
4141

42-
write!(unformatted, "{}", gen)?;
42+
write!(unformatted, "{gen}")?;
4343
}
4444

4545
let formatted = match format_generated_code(&unformatted) {
4646
Ok(formatted) => formatted,
4747
Err(e) => {
48-
eprintln!("Failed to format generated code: {}", e);
48+
eprintln!("Failed to format generated code: {e}");
4949
unformatted
5050
}
5151
};
@@ -86,16 +86,15 @@ fn write_doc_header<W: std::fmt::Write>(
8686
write!(
8787
w,
8888
"//!
89-
//! This code was generated by `{}` `{}` from D-Bus introspection data.
90-
//! Source: `{}`.
89+
//! This code was generated by `{cargo_bin_name}` `{cargo_bin_version}` from D-Bus introspection data.
90+
//! Source: `{input_src}`.
9191
//!
9292
//! You may prefer to adapt it, instead of using it verbatim.
9393
//!
9494
//! More information can be found in the [Writing a client proxy] section of the zbus
9595
//! documentation.
9696
//!
9797
",
98-
cargo_bin_name, cargo_bin_version, input_src,
9998
)?;
10099

101100
if !standard_interfaces.is_empty() {
@@ -112,9 +111,8 @@ fn write_doc_header<W: std::fmt::Write>(
112111
write!(
113112
w,
114113
"//!
115-
//! Consequently `{}` did not generate code for the above interfaces.
114+
//! Consequently `{cargo_bin_name}` did not generate code for the above interfaces.
116115
",
117-
cargo_bin_name,
118116
)?;
119117
}
120118

@@ -145,7 +143,7 @@ impl Display for GenTrait<'_> {
145143

146144
let formatted = format_generated_code(&unformatted).unwrap_or(unformatted);
147145

148-
write!(f, "{}", formatted)
146+
write!(f, "{formatted}")
149147
} else {
150148
self.write_interface(f)
151149
}
@@ -213,14 +211,14 @@ impl GenTrait<'_> {
213211
writeln!(w)?;
214212
writeln!(w, " /// {} property", p.name())?;
215213
if p.access().read() {
216-
writeln!(w, "{}", fn_attribute)?;
214+
writeln!(w, "{fn_attribute}")?;
217215
let output = to_rust_type(p.ty(), false, false);
218216
hide_clippy_type_complexity_lint(w, p.ty())?;
219217
writeln!(w, " fn {name}(&self) -> zbus::Result<{output}>;",)?;
220218
}
221219

222220
if p.access().write() {
223-
writeln!(w, "{}", fn_attribute)?;
221+
writeln!(w, "{fn_attribute}")?;
224222
let input = to_rust_type(p.ty(), true, true);
225223
writeln!(
226224
w,
@@ -363,16 +361,16 @@ fn to_rust_type(ty: &Signature, input: bool, as_ref: bool) -> String {
363361
Signature::Array(child) => {
364362
let child_ty = signature_to_rust_type(child, input, as_ref);
365363
if input && as_ref {
366-
format!("&[{}]", child_ty)
364+
format!("&[{child_ty}]")
367365
} else {
368-
format!("Vec<{}>", child_ty)
366+
format!("Vec<{child_ty}>")
369367
}
370368
}
371369
Signature::Dict { key, value } => {
372370
let key_ty = signature_to_rust_type(key, input, as_ref);
373371
let value_ty = signature_to_rust_type(value, input, as_ref);
374372

375-
format!("std::collections::HashMap<{}, {}>", key_ty, value_ty)
373+
format!("std::collections::HashMap<{key_ty}, {value_ty}>")
376374
}
377375
Signature::Structure(fields) => {
378376
let fields = fields

0 commit comments

Comments
 (0)