Skip to content

Commit

Permalink
Bump MSRV for expect attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
GnomedDev committed Nov 6, 2024
1 parent 5a19a3b commit 808bec5
Show file tree
Hide file tree
Showing 26 changed files with 33 additions and 43 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ name: CI
on: [push, pull_request]

env:
rust_min: 1.79.0
rust_nightly: nightly-2024-06-21
rust_min: 1.82.0
rust_nightly: nightly-2024-11-01

jobs:
test:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ readme = "README.md"
repository = "https://github.com/serenity-rs/serenity.git"
version = "0.12.2"
edition = "2021"
rust-version = "1.79"
rust-version = "1.82.0"
include = ["src/**/*", "LICENSE.md", "README.md", "CHANGELOG.md", "build.rs"]

[workspace]
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ tokio = { version = "1.21.2", features = ["macros", "rt-multi-thread"] }

## MSRV Policy

Serenity's minimum supported Rust version (MSRV) is Rust 1.79.
Serenity's minimum supported Rust version (MSRV) is Rust 1.82.

We opt to keep MSRV stable on the `current` branch. This means it will remain
unchanged between minor releases. Occasionally, dependencies may violate SemVer
Expand Down Expand Up @@ -244,5 +244,5 @@ a Rust-native cloud development platform that allows deploying Serenity bots for
[repo:andesite]: https://github.com/natanbc/andesite
[repo:lavaplayer]: https://github.com/sedmelluq/lavaplayer
[logo]: https://raw.githubusercontent.com/serenity-rs/serenity/current/logo.png
[rust-version-badge]: https://img.shields.io/badge/rust-1.79.0+-93450a.svg?style=flat-square
[rust-version-link]: https://blog.rust-lang.org/2024/06/13/Rust-1.79.0.html
[rust-version-badge]: https://img.shields.io/badge/rust-1.82.0+-93450a.svg?style=flat-square
[rust-version-link]: https://blog.rust-lang.org/2024/10/17/Rust-1.82.0.html
6 changes: 3 additions & 3 deletions src/builder/create_attachment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use serde::ser::{Serialize, SerializeSeq, Serializer};
use tokio::fs::File;
use tokio::io::AsyncReadExt;

#[allow(unused)] // Error is used in docs
#[expect(unused)] // Error is used in docs
use crate::error::{Error, Result};
#[cfg(feature = "http")]
use crate::http::Http;
Expand Down Expand Up @@ -232,7 +232,7 @@ impl<'a> EditAttachments<'a> {
///
/// Opposite of [`Self::keep`].
pub fn remove(mut self, id: AttachmentId) -> Self {
#[allow(clippy::match_like_matches_macro)] // `matches!` is less clear here
#[expect(clippy::match_like_matches_macro)] // `matches!` is less clear here
self.new_and_existing_attachments.retain(|a| match a {
NewOrExisting::Existing(a) if a.id == id => false,
_ => true,
Expand All @@ -241,7 +241,7 @@ impl<'a> EditAttachments<'a> {
}

/// Adds a new attachment to the attachment list.
#[allow(clippy::should_implement_trait)] // Clippy thinks add == std::ops::Add::add
#[expect(clippy::should_implement_trait)] // Clippy thinks add == std::ops::Add::add
pub fn add(mut self, attachment: CreateAttachment<'a>) -> Self {
self.new_and_existing_attachments.push(NewOrExisting::New(attachment));
self
Expand Down
2 changes: 1 addition & 1 deletion src/builder/create_components.rs
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ impl Serialize for CreateSelectMenuKind<'_> {
default_values: &'a [CreateSelectMenuDefault],
}

#[allow(clippy::ref_option)]
#[expect(clippy::ref_option)]
fn map<'a>(
values: &'a Option<Cow<'a, [impl Into<Mention> + Copy]>>,
) -> impl Iterator<Item = CreateSelectMenuDefault> + 'a {
Expand Down
2 changes: 1 addition & 1 deletion src/gateway/ws.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ impl WsClient {
Ok(())
}

#[allow(clippy::missing_errors_doc)]
#[expect(clippy::missing_errors_doc)]
pub async fn send_chunk_guild(
&mut self,
guild_id: GuildId,
Expand Down
2 changes: 1 addition & 1 deletion src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3063,7 +3063,7 @@ impl Http {
.await
}

#[allow(clippy::too_many_arguments)]
#[expect(clippy::too_many_arguments)]
/// Gets all entitlements for the current app, active and expired.
pub async fn get_entitlements(
&self,
Expand Down
2 changes: 1 addition & 1 deletion src/http/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ impl StdError for HttpError {
}
}

#[allow(clippy::missing_errors_doc)]
#[expect(clippy::missing_errors_doc)]
pub fn deserialize_errors<'de, D: Deserializer<'de>>(
deserializer: D,
) -> StdResult<FixedArray<DiscordJsonSingleError>, D::Error> {
Expand Down
2 changes: 1 addition & 1 deletion src/http/ratelimiting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ mod tests {
}

#[test]
#[allow(clippy::float_cmp)]
#[expect(clippy::float_cmp)]
fn test_parse_header_good() -> Result<()> {
let headers = headers();

Expand Down
2 changes: 1 addition & 1 deletion src/http/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ macro_rules! routes {

#[must_use]
pub fn ratelimiting_bucket(&self) -> RatelimitingBucket {
#[allow(unused_variables)]
#[expect(unused_variables)]
let ratelimiting_kind = match *self {
$(
Self::$name $({ $($field_name),* })? => $ratelimiting_kind,
Expand Down
2 changes: 1 addition & 1 deletion src/http/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ impl Typing {
/// already stopped.
///
/// [`Channel`]: crate::model::channel::Channel
#[allow(clippy::must_use_candidate)]
#[expect(clippy::must_use_candidate)]
pub fn stop(self) -> bool {
self.0.send(()).is_ok()
}
Expand Down
2 changes: 1 addition & 1 deletion src/interactions_endpoint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ impl Verifier {
/// Verifies a Discord request for authenticity, given the `X-Signature-Ed25519` HTTP header,
/// `X-Signature-Timestamp` HTTP headers and request body.
// We just need to differentiate "pass" and "failure". There's deliberately no data besides ().
#[allow(clippy::result_unit_err, clippy::missing_errors_doc)]
#[expect(clippy::result_unit_err, clippy::missing_errors_doc)]
pub fn verify(&self, signature: &str, timestamp: &str, body: &[u8]) -> Result<(), ()> {
use ed25519_dalek::Verifier as _;

Expand Down
1 change: 1 addition & 0 deletions src/internal/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ macro_rules! enum_number {
)?

#[allow(non_snake_case, non_upper_case_globals)]
#[allow(clippy::allow_attributes, reason = "Does not always trigger due to macro")]
impl $Enum {
$(
$(#[doc = $doc])*
Expand Down
1 change: 0 additions & 1 deletion src/model/channel/guild_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@ impl GuildChannel {
/// typing.stop();
/// # }
/// ```
#[allow(clippy::missing_errors_doc)]
pub fn start_typing(&self, http: Arc<Http>) -> Typing {
self.id.start_typing(http)
}
Expand Down
8 changes: 4 additions & 4 deletions src/model/channel/private_channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ impl PrivateChannel {
/// Broadcasts that the current user is typing to the recipient.
///
/// See [ChannelId::broadcast_typing] for more details.
#[allow(clippy::missing_errors_doc)]
#[expect(clippy::missing_errors_doc)]
pub async fn broadcast_typing(&self, http: &Http) -> Result<()> {
self.id.broadcast_typing(http).await
}
Expand All @@ -67,7 +67,7 @@ impl PrivateChannel {

/// Deletes the channel. This does not delete the contents of the channel, and is equivalent to
/// closing a private channel on the client, which can be re-opened.
#[allow(clippy::missing_errors_doc)]
#[expect(clippy::missing_errors_doc)]
pub async fn delete(&self, http: &Http) -> Result<PrivateChannel> {
let resp = self.id.delete(http, None).await?;
resp.private().ok_or(Error::Model(ModelError::InvalidChannelType))
Expand Down Expand Up @@ -96,7 +96,7 @@ impl PrivateChannel {
/// **Note**: Requires the [Manage Channel] permission.
///
/// [Manage Channel]: Permissions::MANAGE_CHANNELS
#[allow(clippy::missing_errors_doc)]
#[expect(clippy::missing_errors_doc)]
pub async fn delete_permission(
&self,
http: &Http,
Expand Down Expand Up @@ -207,7 +207,7 @@ impl PrivateChannel {
}

/// Retrieves the list of messages that have been pinned in the private channel.
#[allow(clippy::missing_errors_doc)]
#[expect(clippy::missing_errors_doc)]
pub async fn pins(&self, http: &Http) -> Result<Vec<Message>> {
self.id.pins(http).await
}
Expand Down
1 change: 0 additions & 1 deletion src/model/colour.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ impl Colour {
/// ```
// Clippy wants to use `u32::from` instead `as`-casts,
// but this not doable as `u32::from` is not a const fn.
#[allow(clippy::cast_lossless)]
#[must_use]
pub const fn from_rgb(red: u8, green: u8, blue: u8) -> Colour {
Colour((red as u32) << 16 | (green as u32) << 8 | blue as u32)
Expand Down
2 changes: 1 addition & 1 deletion src/model/event.rs
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,7 @@ pub struct MessageUpdateEvent {
}

impl MessageUpdateEvent {
#[allow(clippy::clone_on_copy)] // For consistency between fields
#[expect(clippy::clone_on_copy)] // For consistency between fields
#[rustfmt::skip]
/// Writes the updated data in this message update event into the given [`Message`].
pub fn apply_to_message(&self, message: &mut Message) {
Expand Down
1 change: 0 additions & 1 deletion src/model/guild/audit_log/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@ impl Action {
}

#[must_use]
#[allow(unknown_lints, clippy::missing_transmute_annotations)]
pub fn from_value(value: u8) -> Action {
match value {
1 => Action::GuildUpdate,
Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/audit_log/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ pub mod optional_string {
deserializer.deserialize_option(OptionalStringVisitor::<T>(PhantomData))
}

#[allow(clippy::ref_option)]
#[expect(clippy::ref_option)]
pub fn serialize<S: Serializer>(
value: &Option<impl ToString>,
serializer: S,
Expand Down
6 changes: 1 addition & 5 deletions src/model/guild/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -813,11 +813,7 @@ impl Guild {
/// Returns [`Error::Http`] if the current user lacks permission or if invalid data is given.
///
/// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS
pub async fn create_sticker<'a>(
&self,
http: &Http,
builder: CreateSticker<'a>,
) -> Result<Sticker> {
pub async fn create_sticker(&self, http: &Http, builder: CreateSticker<'_>) -> Result<Sticker> {
self.id.create_sticker(http, builder).await
}

Expand Down
6 changes: 1 addition & 5 deletions src/model/guild/partial_guild.rs
Original file line number Diff line number Diff line change
Expand Up @@ -584,11 +584,7 @@ impl PartialGuild {
/// Returns [`Error::Http`] if the current user lacks permission or if invalid data is given.
///
/// [Create Guild Expressions]: Permissions::CREATE_GUILD_EXPRESSIONS
pub async fn create_sticker<'a>(
&self,
http: &Http,
builder: CreateSticker<'a>,
) -> Result<Sticker> {
pub async fn create_sticker(&self, http: &Http, builder: CreateSticker<'_>) -> Result<Sticker> {
self.id.create_sticker(http, builder).await
}

Expand Down
2 changes: 1 addition & 1 deletion src/model/guild/role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ mod bool_as_option_unit {
deserializer.deserialize_option(NullValueVisitor)
}

#[allow(clippy::trivially_copy_pass_by_ref)]
#[expect(clippy::trivially_copy_pass_by_ref)]
pub fn serialize<S: Serializer>(_: &bool, serializer: S) -> Result<S::Ok, S::Error> {
serializer.serialize_none()
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ mod snowflake {
deserializer.deserialize_any(SnowflakeVisitor)
}

#[allow(clippy::trivially_copy_pass_by_ref)]
#[expect(clippy::trivially_copy_pass_by_ref)]
pub fn serialize<S: Serializer>(id: &NonMaxU64, serializer: S) -> Result<S::Ok, S::Error> {
serializer.collect_str(&id.get())
}
Expand Down
6 changes: 3 additions & 3 deletions src/model/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ pub(crate) mod discriminator {
deserializer.deserialize_option(OptionalDiscriminatorVisitor)
}

#[allow(clippy::trivially_copy_pass_by_ref, clippy::ref_option)]
#[expect(clippy::trivially_copy_pass_by_ref, clippy::ref_option)]
pub fn serialize<S: Serializer>(
value: &Option<NonZeroU16>,
serializer: S,
Expand Down Expand Up @@ -433,7 +433,7 @@ impl User {
}

/// This is an alias of [`Self::direct_message`].
#[allow(clippy::missing_errors_doc)]
#[expect(clippy::missing_errors_doc)]
pub async fn dm(&self, http: &Http, builder: CreateMessage<'_>) -> Result<Message> {
self.direct_message(http, builder).await
}
Expand Down Expand Up @@ -677,7 +677,7 @@ impl UserId {
}

/// This is an alias of [`Self::direct_message`].
#[allow(clippy::missing_errors_doc)]
#[expect(clippy::missing_errors_doc)]
pub async fn dm(self, http: &Http, builder: CreateMessage<'_>) -> Result<Message> {
self.direct_message(http, builder).await
}
Expand Down
2 changes: 1 addition & 1 deletion src/model/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub fn default_true() -> bool {
}

/// Helper function for `#[serde(skip_serializing_if = "is_false")]`
#[allow(clippy::trivially_copy_pass_by_ref)]
#[expect(clippy::trivially_copy_pass_by_ref)]
pub fn is_false(v: &bool) -> bool {
!v
}
Expand Down
2 changes: 1 addition & 1 deletion src/utils/content_safe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ fn clean_mention(
}
}

#[allow(clippy::non_ascii_literal)]
#[expect(clippy::non_ascii_literal)]
#[cfg(test)]
mod tests {
use small_fixed_array::FixedString;
Expand Down

0 comments on commit 808bec5

Please sign in to comment.