Skip to content

Commit bb96102

Browse files
authored
Fix clippy warnings/MSRV on current (#3371)
1 parent 9108d28 commit bb96102

File tree

9 files changed

+49
-2
lines changed

9 files changed

+49
-2
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ jobs:
166166
run: |
167167
cargo update idna_adapter --precise 1.1.0
168168
cargo update triomphe --precise 0.1.11
169+
cargo update base64ct --precise 1.7.3
169170
170171
- name: Check
171172
run: cargo check --features full

src/client/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -665,6 +665,10 @@ impl Client {
665665
/// # }
666666
/// ```
667667
///
668+
/// # Errors
669+
///
670+
/// Returns a [`ClientError::Shutdown`] when all shards have shutdown due to an error.
671+
///
668672
/// [gateway docs]: crate::gateway#sharding
669673
#[instrument(skip(self))]
670674
pub async fn start(&mut self) -> Result<()> {

src/framework/standard/parse/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ fn permissions_in(
3030
roles: &HashMap<RoleId, Role>,
3131
) -> Permissions {
3232
let guild = ctx.cache.guild(guild_id);
33-
if guild.as_ref().map(|guild| member.user.id == guild.owner_id) == Some(true) {
33+
if guild.as_ref().is_some_and(|guild| member.user.id == guild.owner_id) {
3434
return Permissions::all();
3535
}
3636

src/gateway/bridge/shard_manager.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ impl ShardManager {
182182
/// This will communicate shard boots with the [`ShardQueuer`] so that they are properly
183183
/// queued.
184184
#[instrument(skip(self))]
185+
#[allow(clippy::missing_errors_doc)] // Doesn't actually error, fixed on next.
185186
pub fn initialize(&self) -> Result<()> {
186187
let shard_index = self.shard_index.load(Ordering::Relaxed);
187188
let shard_init = self.shard_init.load(Ordering::Relaxed);

src/gateway/bridge/shard_runner.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ impl ShardRunner {
9393
///
9494
/// 6. Go back to 1.
9595
///
96+
/// # Errors
97+
///
98+
/// Returns an error if authentication fails or the intents contained disallowed values.
99+
///
96100
/// [`ShardManager`]: super::ShardManager
97101
#[instrument(skip(self))]
98102
pub async fn run(&mut self) -> Result<()> {

src/gateway/shard.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,9 @@ impl Shard {
630630
/// # }
631631
/// ```
632632
///
633+
/// # Errors
634+
/// Errors if there is a problem with the WS connection.
635+
///
633636
/// [`Event::GuildMembersChunk`]: crate::model::event::Event::GuildMembersChunk
634637
/// [`Guild`]: crate::model::guild::Guild
635638
/// [`Member`]: crate::model::guild::Member
@@ -650,6 +653,9 @@ impl Shard {
650653
/// Sets the shard as going into identifying stage, which sets:
651654
/// - the time that the last heartbeat sent as being now
652655
/// - the `stage` to [`ConnectionStage::Identifying`]
656+
///
657+
/// # Errors
658+
/// Errors if there is a problem with the WS connection.
653659
#[instrument(skip(self))]
654660
pub async fn identify(&mut self) -> Result<()> {
655661
self.client.send_identify(&self.info, &self.token, self.intents, &self.presence).await?;
@@ -663,6 +669,10 @@ impl Shard {
663669
/// Initializes a new WebSocket client.
664670
///
665671
/// This will set the stage of the shard before and after instantiation of the client.
672+
///
673+
/// # Errors
674+
///
675+
/// Errors if unable to establish a websocket connection.
666676
#[instrument(skip(self))]
667677
pub async fn initialize(&mut self) -> Result<WsClient> {
668678
debug!("[{:?}] Initializing.", self.info);
@@ -694,6 +704,9 @@ impl Shard {
694704
self.seq = 0;
695705
}
696706

707+
/// # Errors
708+
///
709+
/// Errors if unable to re-establish a websocket connection.
697710
#[instrument(skip(self))]
698711
pub async fn resume(&mut self) -> Result<()> {
699712
debug!("[{:?}] Attempting to resume", self.info);
@@ -709,6 +722,9 @@ impl Shard {
709722
}
710723
}
711724

725+
/// # Errors
726+
///
727+
/// Errors if unable to re-establish a websocket connection.
712728
#[instrument(skip(self))]
713729
pub async fn reconnect(&mut self) -> Result<()> {
714730
info!("[{:?}] Attempting to reconnect", self.shard_info());
@@ -719,6 +735,9 @@ impl Shard {
719735
Ok(())
720736
}
721737

738+
/// # Errors
739+
///
740+
/// Errors if there is a problem with the WS connection.
722741
#[instrument(skip(self))]
723742
pub async fn update_presence(&mut self) -> Result<()> {
724743
self.client.send_presence_update(&self.info, &self.presence).await

src/gateway/ws.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,9 @@ impl WsClient {
180180
Ok(())
181181
}
182182

183-
#[allow(clippy::missing_errors_doc)]
183+
/// # Errors
184+
///
185+
/// Errors if there is a problem with the WS connection.
184186
pub async fn send_chunk_guild(
185187
&mut self,
186188
guild_id: GuildId,
@@ -212,6 +214,9 @@ impl WsClient {
212214
.await
213215
}
214216

217+
/// # Errors
218+
///
219+
/// Errors if there is a problem with the WS connection.
215220
#[instrument(skip(self))]
216221
pub async fn send_heartbeat(&mut self, shard_info: &ShardInfo, seq: Option<u64>) -> Result<()> {
217222
trace!("[{:?}] Sending heartbeat d: {:?}", shard_info, seq);
@@ -223,6 +228,9 @@ impl WsClient {
223228
.await
224229
}
225230

231+
/// # Errors
232+
///
233+
/// Errors if there is a problem with the WS connection.
226234
#[instrument(skip(self, token))]
227235
pub async fn send_identify(
228236
&mut self,
@@ -261,6 +269,9 @@ impl WsClient {
261269
self.send_json(&msg).await
262270
}
263271

272+
/// # Errors
273+
///
274+
/// Errors if there is a problem with the WS connection.
264275
#[instrument(skip(self))]
265276
pub async fn send_presence_update(
266277
&mut self,
@@ -284,6 +295,9 @@ impl WsClient {
284295
.await
285296
}
286297

298+
/// # Errors
299+
///
300+
/// Errors if there is a problem with the WS connection.
287301
#[instrument(skip(self, token))]
288302
pub async fn send_resume(
289303
&mut self,

src/http/ratelimiting.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ impl Ratelimit {
323323
self.remaining -= 1;
324324
}
325325

326+
/// # Errors
327+
///
328+
/// Errors if parsing headers from the response fails.
326329
#[instrument(skip(ratelimit_callback))]
327330
pub async fn post_hook(
328331
&mut self,

src/http/request.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ impl<'a> Request<'a> {
6363
self
6464
}
6565

66+
#[allow(clippy::missing_errors_doc)]
6667
#[instrument(skip(token))]
6768
pub fn build(
6869
self,

0 commit comments

Comments
 (0)