From 8956352f13659fff48522f62e4eb7b2776779b2e Mon Sep 17 00:00:00 2001 From: Gnome! Date: Mon, 5 May 2025 13:58:15 +0100 Subject: [PATCH] Fix clippy warnings (#275) --- src/driver/crypto.rs | 4 ++-- src/driver/tasks/mixer/mix_logic.rs | 2 +- src/driver/tasks/mixer/mod.rs | 7 +++---- src/input/adapters/cached/compressed.rs | 4 ++-- src/input/sources/http.rs | 3 +-- src/lib.rs | 15 +++++++++------ 6 files changed, 18 insertions(+), 17 deletions(-) diff --git a/src/driver/crypto.rs b/src/driver/crypto.rs index 36c4be3..521ee95 100644 --- a/src/driver/crypto.rs +++ b/src/driver/crypto.rs @@ -581,7 +581,7 @@ mod test { // If there is no mutual intelligibility, return an error. let bad_modes = ["not_real", "des", "rc5"]; - assert!(CryptoMode::negotiate(&bad_modes, None).is_err()); - assert!(CryptoMode::negotiate(&bad_modes, Some(CryptoMode::Aes256Gcm)).is_err()); + assert!(CryptoMode::negotiate(bad_modes, None).is_err()); + assert!(CryptoMode::negotiate(bad_modes, Some(CryptoMode::Aes256Gcm)).is_err()); } } diff --git a/src/driver/tasks/mixer/mix_logic.rs b/src/driver/tasks/mixer/mix_logic.rs index b71806b..fd91a6a 100644 --- a/src/driver/tasks/mixer/mix_logic.rs +++ b/src/driver/tasks/mixer/mix_logic.rs @@ -246,7 +246,7 @@ pub fn mix_symph_indiv( resample_in_progress = true; continue; } - }; + } let samples_marched = mix_resampled(rs_out_buf, symph_mix, samples_written, volume); diff --git a/src/driver/tasks/mixer/mod.rs b/src/driver/tasks/mixer/mod.rs index a0ac696..39eea78 100644 --- a/src/driver/tasks/mixer/mod.rs +++ b/src/driver/tasks/mixer/mod.rs @@ -679,12 +679,11 @@ impl Mixer { Ok(()) } else { - self._send_packet(packet) + self.send_packet_(packet) }; #[cfg(not(test))] - #[allow(clippy::used_underscore_items)] - let send_status = self._send_packet(packet); + let send_status = self.send_packet_(packet); send_status.or_else(Error::disarm_would_block)?; @@ -692,7 +691,7 @@ impl Mixer { } #[inline] - fn _send_packet(&self, packet: &[u8]) -> Result<()> { + fn send_packet_(&self, packet: &[u8]) -> Result<()> { let conn = self .conn_active .as_ref() diff --git a/src/input/adapters/cached/compressed.rs b/src/input/adapters/cached/compressed.rs index 9ff3bca..08f8871 100644 --- a/src/input/adapters/cached/compressed.rs +++ b/src/input/adapters/cached/compressed.rs @@ -434,7 +434,7 @@ where }, Err(e) => { debug!("Read error {:?} {:?} {:?}.", e, out, raw_len); - out = Some(Err(IoError::new(IoErrorKind::Other, e))); + out = Some(Err(IoError::other(e))); break; }, } @@ -472,7 +472,7 @@ where // NOTE: use of raw_len here preserves true sample length even if // stream is extended to 20ms boundary. - out.unwrap_or_else(|| Err(IoError::new(IoErrorKind::Other, "Unclear."))) + out.unwrap_or_else(|| Err(IoError::other("Unclear."))) .map(|compressed_sz| { self.audio_bytes .fetch_add(raw_len * mem::size_of::(), Ordering::Release); diff --git a/src/input/sources/http.rs b/src/input/sources/http.rs index bc7a45f..8eba4e9 100644 --- a/src/input/sources/http.rs +++ b/src/input/sources/http.rs @@ -132,8 +132,7 @@ impl HttpRequest { }); let stream = Box::new(StreamReader::new( - resp.bytes_stream() - .map_err(|e| IoError::new(IoErrorKind::Other, e)), + resp.bytes_stream().map_err(IoError::other), )); let input = HttpStream { diff --git a/src/lib.rs b/src/lib.rs index 4c0a458..2c62a42 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -10,15 +10,15 @@ //! Songbird is an async, cross-library compatible voice system for Discord, written in Rust. //! The library offers: //! * A standalone gateway frontend compatible with [serenity] and [twilight] using the -//! `"gateway"` and `"[serenity/twilight]"` plus `"[rustls/native]"` features. You can even run -//! driverless, to help manage your [lavalink] sessions. +//! `"gateway"` and `"[serenity/twilight]"` plus `"[rustls/native]"` features. You can even run +//! driverless, to help manage your [lavalink] sessions. //! * A standalone driver for voice calls, via the `"driver"` feature. If you can create -//! a `ConnectionInfo` using any other gateway, or language for your bot, then you -//! can run the songbird voice driver. +//! a `ConnectionInfo` using any other gateway, or language for your bot, then you +//! can run the songbird voice driver. //! * Voice receive and RT(C)P packet handling via the `"receive"` feature. //! * And, by default, a fully featured voice system featuring events, queues, -//! seeking on compatible streams, shared multithreaded audio stream caches, -//! and direct Opus data passthrough from DCA files. +//! seeking on compatible streams, shared multithreaded audio stream caches, +//! and direct Opus data passthrough from DCA files. //! //! ## Intents //! Songbird's gateway functionality requires you to specify the `GUILD_VOICE_STATES` intent. @@ -77,6 +77,9 @@ clippy::missing_panics_doc, clippy::doc_link_with_quotes, clippy::doc_markdown, + // Allowed as they cannot be fixed without breaking + clippy::result_large_err, + clippy::large_enum_variant, )] mod config;