Skip to content

Commit 3686718

Browse files
authored
Chore: fix clippy warnings for stable (1.87) and nightly (1.89) (#1504)
* chore: stable - fix clippy warnings * chore: nightly - fix clippy warnings
1 parent 8b72954 commit 3686718

6 files changed

Lines changed: 13 additions & 19 deletions

File tree

core/src/mercury/types.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ impl std::fmt::Display for MercuryMethod {
5757
MercuryMethod::Unsub => "UNSUB",
5858
MercuryMethod::Send => "SEND",
5959
};
60-
write!(f, "{}", s)
60+
write!(f, "{s}")
6161
}
6262
}
6363

core/src/proxytunnel.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub async fn proxy_connect<T: AsyncRead + AsyncWrite + Unpin>(
2222
loop {
2323
let bytes_read = proxy_connection.read(&mut buffer[offset..]).await?;
2424
if bytes_read == 0 {
25-
return Err(io::Error::new(io::ErrorKind::Other, "Early EOF from proxy"));
25+
return Err(io::Error::other("Early EOF from proxy"));
2626
}
2727
offset += bytes_read;
2828

@@ -31,20 +31,17 @@ pub async fn proxy_connect<T: AsyncRead + AsyncWrite + Unpin>(
3131

3232
let status = response
3333
.parse(&buffer[..offset])
34-
.map_err(|err| io::Error::new(io::ErrorKind::Other, err))?;
34+
.map_err(io::Error::other)?;
3535

3636
if status.is_complete() {
3737
return match response.code {
3838
Some(200) => Ok(proxy_connection), // Proxy says all is well
3939
Some(code) => {
4040
let reason = response.reason.unwrap_or("no reason");
4141
let msg = format!("Proxy responded with {code}: {reason}");
42-
Err(io::Error::new(io::ErrorKind::Other, msg))
42+
Err(io::Error::other(msg))
4343
}
44-
None => Err(io::Error::new(
45-
io::ErrorKind::Other,
46-
"Malformed response from proxy",
47-
)),
44+
None => Err(io::Error::other("Malformed response from proxy")),
4845
};
4946
}
5047

discovery/src/lib.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,10 @@ pub fn find(name: Option<&str>) -> Result<DnsSdServiceBuilder, Error> {
9696
match BACKENDS.iter().find(|(id, _)| name == id) {
9797
Some((_id, Some(launch_svc))) => Ok(*launch_svc),
9898
Some((_id, None)) => Err(Error::unavailable(format!(
99-
"librespot built without '{}' support",
100-
name
99+
"librespot built without '{name}' support"
101100
))),
102101
None => Err(Error::not_found(format!(
103-
"unknown zeroconf backend '{}'",
104-
name
102+
"unknown zeroconf backend '{name}'"
105103
))),
106104
}
107105
} else {
@@ -286,14 +284,14 @@ async fn avahi_task(
286284
//
287285
// EntryGroup has been withdrawn at this point already!
288286
log::error!("zeroconf collision for name '{}'", &name);
289-
return Err(zbus::Error::Failure(format!("zeroconf collision for name: {}", name)).into());
287+
return Err(zbus::Error::Failure(format!("zeroconf collision for name: {name}")).into());
290288
}
291289
EntryGroupState::Failure => {
292290
// TODO: Back off/treat as fatal?
293291
// EntryGroup has been withdrawn at this point already!
294292
// There seems to be no code in Avahi that actually sets this state.
295293
log::error!("zeroconf failure: {}", error);
296-
return Err(zbus::Error::Failure(format!("zeroconf failure: {}", error)).into());
294+
return Err(zbus::Error::Failure(format!("zeroconf failure: {error}")).into());
297295
}
298296
}
299297
}

oauth/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl OAuthClient {
237237
if self.should_open_url {
238238
open::that_in_background(auth_url.as_str());
239239
}
240-
println!("Browse to: {}", auth_url);
240+
println!("Browse to: {auth_url}");
241241

242242
pkce_verifier
243243
}
@@ -456,7 +456,7 @@ pub fn get_access_token(
456456
.set_pkce_challenge(pkce_challenge)
457457
.url();
458458

459-
println!("Browse to: {}", auth_url);
459+
println!("Browse to: {auth_url}");
460460

461461
let code = match get_socket_address(redirect_uri) {
462462
Some(addr) => get_authcode_listener(addr, String::from("Go back to your terminal :)")),

playback/src/mixer/mappings.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,6 @@ impl CubicMapping {
158158
fn min_norm(db_range: f64) -> f64 {
159159
// Note that this 60.0 is unrelated to DEFAULT_DB_RANGE.
160160
// Instead, it's the cubic voltage to dB ratio.
161-
f64::powf(10.0, -1.0 * db_range / 60.0)
161+
f64::powf(10.0, -db_range / 60.0)
162162
}
163163
}

src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,8 +1227,7 @@ fn get_setup() -> Setup {
12271227
Some("librespot compiled without zeroconf backend".to_owned())
12281228
} else if opt_present(DISABLE_DISCOVERY) {
12291229
Some(format!(
1230-
"the `--{}` / `-{}` flag set",
1231-
DISABLE_DISCOVERY, DISABLE_DISCOVERY_SHORT,
1230+
"the `--{DISABLE_DISCOVERY}` / `-{DISABLE_DISCOVERY_SHORT}` flag set",
12321231
))
12331232
} else {
12341233
None

0 commit comments

Comments
 (0)