From 98c5da42019d23e232c040516531889fc548bb5f Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 30 Nov 2025 14:35:23 +0000 Subject: [PATCH 1/7] fix: clippy::redundant_closure_for_method_calls --- audio/src/fetch/receive.rs | 2 +- core/src/http_client.rs | 2 +- core/src/spclient.rs | 6 +++--- metadata/src/image.rs | 2 +- metadata/src/lyrics.rs | 2 +- metadata/src/playlist/attribute.rs | 4 ++-- metadata/src/playlist/list.rs | 4 ++-- metadata/src/playlist/permission.rs | 2 +- metadata/src/restriction.rs | 4 ++-- oauth/src/lib.rs | 2 +- playback/src/local_file.rs | 2 +- src/main.rs | 2 +- 12 files changed, 17 insertions(+), 17 deletions(-) diff --git a/audio/src/fetch/receive.rs b/audio/src/fetch/receive.rs index 4c894cf61..be6ef835e 100644 --- a/audio/src/fetch/receive.rs +++ b/audio/src/fetch/receive.rs @@ -99,7 +99,7 @@ async fn receive_data( } let body = response.into_body(); - let data = match body.collect().await.map(|b| b.to_bytes()) { + let data = match body.collect().await.map(http_body_util::Collected::to_bytes) { Ok(bytes) => bytes, Err(e) => break Err(e.into()), }; diff --git a/core/src/http_client.rs b/core/src/http_client.rs index bbd63838a..d2b7159e3 100644 --- a/core/src/http_client.rs +++ b/core/src/http_client.rs @@ -242,7 +242,7 @@ impl HttpClient { // strip the prefix from *.domain.tld (assume rate limit is per domain, not subdomain) let mut parts = host .split('.') - .map(|s| s.to_string()) + .map(std::string::ToString::to_string) .collect::>(); let n = parts.len().saturating_sub(2); parts.drain(n..).collect() diff --git a/core/src/spclient.rs b/core/src/spclient.rs index b7c9c51bd..62a370208 100644 --- a/core/src/spclient.rs +++ b/core/src/spclient.rs @@ -422,7 +422,7 @@ impl SpClient { let mut headers = headers.unwrap_or_default(); headers.insert(ACCEPT, HeaderValue::from_static("application/json")); - self.request(method, endpoint, Some(headers), body.map(|s| s.as_bytes())) + self.request(method, endpoint, Some(headers), body.map(str::as_bytes)) .await } @@ -749,7 +749,7 @@ impl SpClient { let previous_track_str = previous_tracks .iter() - .map(|track| track.to_base62()) + .map(super::spotify_id::SpotifyId::to_base62) .collect::>() .join(","); // better than checking `previous_tracks.len() > 0` because the `filter_map` could still return 0 items @@ -952,7 +952,7 @@ impl SpClient { &Method::POST, &endpoint, None, - body.as_deref().map(|s| s.as_bytes()), + body.as_deref().map(str::as_bytes), &NO_METRICS_AND_SALT, ) .await diff --git a/metadata/src/image.rs b/metadata/src/image.rs index 4d2012185..56f7b687f 100644 --- a/metadata/src/image.rs +++ b/metadata/src/image.rs @@ -27,7 +27,7 @@ pub struct Images(pub Vec); impl From<&ImageGroup> for Images { fn from(image_group: &ImageGroup) -> Self { - Self(image_group.image.iter().map(|i| i.into()).collect()) + Self(image_group.image.iter().map(std::convert::Into::into).collect()) } } diff --git a/metadata/src/lyrics.rs b/metadata/src/lyrics.rs index 4a3095e18..87acc9f15 100644 --- a/metadata/src/lyrics.rs +++ b/metadata/src/lyrics.rs @@ -24,7 +24,7 @@ impl TryFrom<&Bytes> for Lyrics { type Error = Error; fn try_from(lyrics: &Bytes) -> Result { - serde_json::from_slice(lyrics).map_err(|err| err.into()) + serde_json::from_slice(lyrics).map_err(std::convert::Into::into) } } diff --git a/metadata/src/playlist/attribute.rs b/metadata/src/playlist/attribute.rs index 86a8f6c55..0bfdcba58 100644 --- a/metadata/src/playlist/attribute.rs +++ b/metadata/src/playlist/attribute.rs @@ -144,7 +144,7 @@ impl TryFrom<&PlaylistPartialAttributesMessage> for PlaylistPartialAttributes { no_value: attributes .no_value .iter() - .map(|v| v.enum_value_or_default()) + .map(protobuf::EnumOrUnknown::enum_value_or_default) .collect::>() .as_slice() .into(), @@ -160,7 +160,7 @@ impl TryFrom<&PlaylistPartialItemAttributesMessage> for PlaylistPartialItemAttri no_value: attributes .no_value .iter() - .map(|v| v.enum_value_or_default()) + .map(protobuf::EnumOrUnknown::enum_value_or_default) .collect::>() .as_slice() .into(), diff --git a/metadata/src/playlist/list.rs b/metadata/src/playlist/list.rs index 1052afd88..68314e7e6 100644 --- a/metadata/src/playlist/list.rs +++ b/metadata/src/playlist/list.rs @@ -169,7 +169,7 @@ impl TryFrom<&::Message> for SelectedListContent { playlist .resulting_revisions .iter() - .map(|p| p.try_into()) + .map(std::convert::TryInto::try_into) .collect::, Error>>()?, ), has_multiple_heads: playlist.multiple_heads(), @@ -183,7 +183,7 @@ impl TryFrom<&::Message> for SelectedListContent { playlist .geoblock .iter() - .map(|b| b.enum_value_or_default()) + .map(protobuf::EnumOrUnknown::enum_value_or_default) .collect(), ), }) diff --git a/metadata/src/playlist/permission.rs b/metadata/src/playlist/permission.rs index ebb179a8d..fe8eb0a33 100644 --- a/metadata/src/playlist/permission.rs +++ b/metadata/src/playlist/permission.rs @@ -33,7 +33,7 @@ impl From<&CapabilitiesMessage> for Capabilities { playlist .grantable_level .iter() - .map(|l| l.enum_value_or_default()) + .map(protobuf::EnumOrUnknown::enum_value_or_default) .collect(), ), can_edit_metadata: playlist.can_edit_metadata(), diff --git a/metadata/src/restriction.rs b/metadata/src/restriction.rs index df9de425e..eeed6928d 100644 --- a/metadata/src/restriction.rs +++ b/metadata/src/restriction.rs @@ -35,7 +35,7 @@ impl Restriction { fn parse_country_codes(country_codes: &str) -> Vec { country_codes .chunks(2) - .map(|country_code| country_code.to_owned()) + .map(std::borrow::ToOwned::to_owned) .collect() } } @@ -58,7 +58,7 @@ impl From<&RestrictionMessage> for Restriction { catalogues: restriction .catalogue .iter() - .map(|c| c.enum_value_or_default()) + .map(protobuf::EnumOrUnknown::enum_value_or_default) .collect::>() .as_slice() .into(), diff --git a/oauth/src/lib.rs b/oauth/src/lib.rs index 70e833391..be369670a 100644 --- a/oauth/src/lib.rs +++ b/oauth/src/lib.rs @@ -493,7 +493,7 @@ pub fn get_access_token( let token_scopes: Vec = match token.scopes() { Some(s) => s.iter().map(|s| s.to_string()).collect(), - _ => scopes.into_iter().map(|s| s.to_string()).collect(), + _ => scopes.into_iter().map(std::string::ToString::to_string).collect(), }; let refresh_token = match token.refresh_token() { Some(t) => t.secret().to_string(), diff --git a/playback/src/local_file.rs b/playback/src/local_file.rs index f25c65829..9ec64afcf 100644 --- a/playback/src/local_file.rs +++ b/playback/src/local_file.rs @@ -27,7 +27,7 @@ pub struct LocalFileLookup(HashMap); impl LocalFileLookup { pub fn get(&self, uri: &SpotifyUri) -> Option<&Path> { - self.0.get(uri).map(|p| p.as_path()) + self.0.get(uri).map(std::path::PathBuf::as_path) } } diff --git a/src/main.rs b/src/main.rs index 92aebb95e..93391d48f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1138,7 +1138,7 @@ async fn get_setup() -> Setup { let cache = { let volume_dir = opt_str(SYSTEM_CACHE) .or_else(|| opt_str(CACHE)) - .map(|p| p.into()); + .map(std::convert::Into::into); let cred_dir = if opt_present(DISABLE_CREDENTIAL_CACHE) { None From 46a5606d2e818f8db8f9737e9b31e46e63a80a9d Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 30 Nov 2025 14:43:33 +0000 Subject: [PATCH 2/7] fixup! fix: clippy::redundant_closure_for_method_calls --- core/src/http_client.rs | 2 +- core/src/spclient.rs | 2 +- metadata/src/image.rs | 2 +- metadata/src/lyrics.rs | 2 +- metadata/src/restriction.rs | 2 +- oauth/src/lib.rs | 2 +- playback/src/local_file.rs | 2 +- src/main.rs | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/core/src/http_client.rs b/core/src/http_client.rs index d2b7159e3..1927ba780 100644 --- a/core/src/http_client.rs +++ b/core/src/http_client.rs @@ -242,7 +242,7 @@ impl HttpClient { // strip the prefix from *.domain.tld (assume rate limit is per domain, not subdomain) let mut parts = host .split('.') - .map(std::string::ToString::to_string) + .map(ToString::to_string) .collect::>(); let n = parts.len().saturating_sub(2); parts.drain(n..).collect() diff --git a/core/src/spclient.rs b/core/src/spclient.rs index 62a370208..e9ca99317 100644 --- a/core/src/spclient.rs +++ b/core/src/spclient.rs @@ -749,7 +749,7 @@ impl SpClient { let previous_track_str = previous_tracks .iter() - .map(super::spotify_id::SpotifyId::to_base62) + .map(SpotifyId::to_base62) .collect::>() .join(","); // better than checking `previous_tracks.len() > 0` because the `filter_map` could still return 0 items diff --git a/metadata/src/image.rs b/metadata/src/image.rs index 56f7b687f..addb6c2f9 100644 --- a/metadata/src/image.rs +++ b/metadata/src/image.rs @@ -27,7 +27,7 @@ pub struct Images(pub Vec); impl From<&ImageGroup> for Images { fn from(image_group: &ImageGroup) -> Self { - Self(image_group.image.iter().map(std::convert::Into::into).collect()) + Self(image_group.image.iter().map(Into::into).collect()) } } diff --git a/metadata/src/lyrics.rs b/metadata/src/lyrics.rs index 87acc9f15..c1cd199c7 100644 --- a/metadata/src/lyrics.rs +++ b/metadata/src/lyrics.rs @@ -24,7 +24,7 @@ impl TryFrom<&Bytes> for Lyrics { type Error = Error; fn try_from(lyrics: &Bytes) -> Result { - serde_json::from_slice(lyrics).map_err(std::convert::Into::into) + serde_json::from_slice(lyrics).map_err(Into::into) } } diff --git a/metadata/src/restriction.rs b/metadata/src/restriction.rs index eeed6928d..efd8d5d48 100644 --- a/metadata/src/restriction.rs +++ b/metadata/src/restriction.rs @@ -35,7 +35,7 @@ impl Restriction { fn parse_country_codes(country_codes: &str) -> Vec { country_codes .chunks(2) - .map(std::borrow::ToOwned::to_owned) + .map(ToOwned::to_owned) .collect() } } diff --git a/oauth/src/lib.rs b/oauth/src/lib.rs index be369670a..7f5f4a582 100644 --- a/oauth/src/lib.rs +++ b/oauth/src/lib.rs @@ -493,7 +493,7 @@ pub fn get_access_token( let token_scopes: Vec = match token.scopes() { Some(s) => s.iter().map(|s| s.to_string()).collect(), - _ => scopes.into_iter().map(std::string::ToString::to_string).collect(), + _ => scopes.into_iter().map(ToString::to_string).collect(), }; let refresh_token = match token.refresh_token() { Some(t) => t.secret().to_string(), diff --git a/playback/src/local_file.rs b/playback/src/local_file.rs index 9ec64afcf..7d99304c2 100644 --- a/playback/src/local_file.rs +++ b/playback/src/local_file.rs @@ -27,7 +27,7 @@ pub struct LocalFileLookup(HashMap); impl LocalFileLookup { pub fn get(&self, uri: &SpotifyUri) -> Option<&Path> { - self.0.get(uri).map(std::path::PathBuf::as_path) + self.0.get(uri).map(PathBuf::as_path) } } diff --git a/src/main.rs b/src/main.rs index 93391d48f..7e7209e1b 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1138,7 +1138,7 @@ async fn get_setup() -> Setup { let cache = { let volume_dir = opt_str(SYSTEM_CACHE) .or_else(|| opt_str(CACHE)) - .map(std::convert::Into::into); + .map(Into::into); let cred_dir = if opt_present(DISABLE_CREDENTIAL_CACHE) { None From 987def6b5c172b56b00af25e797915e2c45bedf0 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 30 Nov 2025 14:54:01 +0000 Subject: [PATCH 3/7] use Into::into --- core/src/http_client.rs | 2 +- metadata/src/restriction.rs | 2 +- oauth/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/http_client.rs b/core/src/http_client.rs index 1927ba780..a7afe18e4 100644 --- a/core/src/http_client.rs +++ b/core/src/http_client.rs @@ -242,7 +242,7 @@ impl HttpClient { // strip the prefix from *.domain.tld (assume rate limit is per domain, not subdomain) let mut parts = host .split('.') - .map(ToString::to_string) + .map(Into::into) .collect::>(); let n = parts.len().saturating_sub(2); parts.drain(n..).collect() diff --git a/metadata/src/restriction.rs b/metadata/src/restriction.rs index efd8d5d48..8c3538ba0 100644 --- a/metadata/src/restriction.rs +++ b/metadata/src/restriction.rs @@ -35,7 +35,7 @@ impl Restriction { fn parse_country_codes(country_codes: &str) -> Vec { country_codes .chunks(2) - .map(ToOwned::to_owned) + .map(Into::into) .collect() } } diff --git a/oauth/src/lib.rs b/oauth/src/lib.rs index 7f5f4a582..707cc5779 100644 --- a/oauth/src/lib.rs +++ b/oauth/src/lib.rs @@ -493,7 +493,7 @@ pub fn get_access_token( let token_scopes: Vec = match token.scopes() { Some(s) => s.iter().map(|s| s.to_string()).collect(), - _ => scopes.into_iter().map(ToString::to_string).collect(), + _ => scopes.into_iter().map(Into::into).collect(), }; let refresh_token = match token.refresh_token() { Some(t) => t.secret().to_string(), From 530aba8d9c32239174369ec8cbd172e706723499 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 30 Nov 2025 15:18:05 +0000 Subject: [PATCH 4/7] use Instant::elapsed --- connect/src/context_resolver.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/connect/src/context_resolver.rs b/connect/src/context_resolver.rs index 1bc0c1631..ce3ecda4d 100644 --- a/connect/src/context_resolver.rs +++ b/connect/src/context_resolver.rs @@ -142,7 +142,7 @@ impl ContextResolver { let last_try = self .unavailable_contexts .get(&resolve) - .map(|i| i.duration_since(Instant::now())); + .map(Instant::elapsed); let last_try = if matches!(last_try, Some(last_try) if last_try > RETRY_UNAVAILABLE) { let _ = self.unavailable_contexts.remove(&resolve); From d2c4ba54788fb292c3c1bfc3448db38a0178f149 Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Sun, 30 Nov 2025 16:20:56 +0000 Subject: [PATCH 5/7] cargo fmt --- audio/src/fetch/receive.rs | 6 +++++- core/src/http_client.rs | 5 +---- metadata/src/restriction.rs | 5 +---- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/audio/src/fetch/receive.rs b/audio/src/fetch/receive.rs index be6ef835e..a1343552c 100644 --- a/audio/src/fetch/receive.rs +++ b/audio/src/fetch/receive.rs @@ -99,7 +99,11 @@ async fn receive_data( } let body = response.into_body(); - let data = match body.collect().await.map(http_body_util::Collected::to_bytes) { + let data = match body + .collect() + .await + .map(http_body_util::Collected::to_bytes) + { Ok(bytes) => bytes, Err(e) => break Err(e.into()), }; diff --git a/core/src/http_client.rs b/core/src/http_client.rs index a7afe18e4..03af57edc 100644 --- a/core/src/http_client.rs +++ b/core/src/http_client.rs @@ -240,10 +240,7 @@ impl HttpClient { let domain = match req.uri().host() { Some(host) => { // strip the prefix from *.domain.tld (assume rate limit is per domain, not subdomain) - let mut parts = host - .split('.') - .map(Into::into) - .collect::>(); + let mut parts = host.split('.').map(Into::into).collect::>(); let n = parts.len().saturating_sub(2); parts.drain(n..).collect() } diff --git a/metadata/src/restriction.rs b/metadata/src/restriction.rs index 8c3538ba0..7a00cefed 100644 --- a/metadata/src/restriction.rs +++ b/metadata/src/restriction.rs @@ -33,10 +33,7 @@ impl_deref_wrapped!(RestrictionCatalogues, Vec); impl Restriction { fn parse_country_codes(country_codes: &str) -> Vec { - country_codes - .chunks(2) - .map(Into::into) - .collect() + country_codes.chunks(2).map(Into::into).collect() } } From 3bb6618cac98467012e50c554d62848ec45c838a Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Wed, 24 Dec 2025 13:05:36 +0000 Subject: [PATCH 6/7] enable clippy lint --- Cargo.toml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index c89262505..71df187bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -209,3 +209,9 @@ assets = [ ["contrib/librespot.service", "lib/systemd/system/", "644"], ["contrib/librespot.user.service", "lib/systemd/user/", "644"], ] + +[workspace.lints] +clippy.redundant_closure_for_method_calls = "warn" + +[lints] +workspace = true From 16696a6fb5fb99d068d367c2b885d436f528e88f Mon Sep 17 00:00:00 2001 From: xtqqczze <45661989+xtqqczze@users.noreply.github.com> Date: Wed, 24 Dec 2025 15:56:09 +0000 Subject: [PATCH 7/7] add lints to all packages --- audio/Cargo.toml | 3 +++ connect/Cargo.toml | 3 +++ core/Cargo.toml | 3 +++ discovery/Cargo.toml | 3 +++ metadata/Cargo.toml | 3 +++ oauth/Cargo.toml | 3 +++ playback/Cargo.toml | 3 +++ protocol/Cargo.toml | 3 +++ 8 files changed, 24 insertions(+) diff --git a/audio/Cargo.toml b/audio/Cargo.toml index fc3cdc94f..ce2e0d769 100644 --- a/audio/Cargo.toml +++ b/audio/Cargo.toml @@ -31,3 +31,6 @@ log = "0.4" tempfile = "3" thiserror = "2" tokio = { version = "1", features = ["macros", "sync"] } + +[lints] +workspace = true diff --git a/connect/Cargo.toml b/connect/Cargo.toml index 95f0e74d5..bc5267f65 100644 --- a/connect/Cargo.toml +++ b/connect/Cargo.toml @@ -31,3 +31,6 @@ thiserror = "2" tokio = { version = "1", features = ["macros", "sync"] } tokio-stream = { version = "0.1", default-features = false } uuid = { version = "1.18", default-features = false, features = ["v4"] } + +[lints] +workspace = true diff --git a/core/Cargo.toml b/core/Cargo.toml index ffe7c1082..2aafe5f45 100644 --- a/core/Cargo.toml +++ b/core/Cargo.toml @@ -118,3 +118,6 @@ vergen-gitcl = { version = "1.0", default-features = false, features = [ [dev-dependencies] tokio = { version = "1", features = ["macros"] } + +[lints] +workspace = true diff --git a/discovery/Cargo.toml b/discovery/Cargo.toml index 17c2c87b5..c7cf4f99f 100644 --- a/discovery/Cargo.toml +++ b/discovery/Cargo.toml @@ -60,3 +60,6 @@ zbus = { version = "5", default-features = false, features = [ futures = "0.3" hex = "0.4" tokio = { version = "1", features = ["macros", "rt"] } + +[lints] +workspace = true diff --git a/metadata/Cargo.toml b/metadata/Cargo.toml index e722f7292..d2b06f488 100644 --- a/metadata/Cargo.toml +++ b/metadata/Cargo.toml @@ -29,3 +29,6 @@ serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "2" uuid = { version = "1", default-features = false } + +[lints] +workspace = true diff --git a/oauth/Cargo.toml b/oauth/Cargo.toml index 89f07db01..320e6e1c5 100644 --- a/oauth/Cargo.toml +++ b/oauth/Cargo.toml @@ -48,3 +48,6 @@ env_logger = { version = "0.11", default-features = false, features = [ "auto-color", ] } tokio = { version = "1", features = ["rt-multi-thread", "macros"] } + +[lints] +workspace = true diff --git a/playback/Cargo.toml b/playback/Cargo.toml index e5656ad10..dd916b55e 100644 --- a/playback/Cargo.toml +++ b/playback/Cargo.toml @@ -97,3 +97,6 @@ rand_distr = "0.5" # Local file handling form_urlencoded = "1.2.2" + +[lints] +workspace = true diff --git a/protocol/Cargo.toml b/protocol/Cargo.toml index 11eb73873..4b0678cae 100644 --- a/protocol/Cargo.toml +++ b/protocol/Cargo.toml @@ -14,3 +14,6 @@ protobuf = "3" [build-dependencies] protobuf-codegen = "3" + +[lints] +workspace = true