Skip to content

Commit

Permalink
chore(clippy, minvers): resolve rust 1.83 issues (#2391)
Browse files Browse the repository at this point in the history
* `serde_derive` < 1.0.113 no longer work with modern rustc versions.
* `used_underscore_items` is a false positive, see
rust-lang/rust-clippy#13478
  • Loading branch information
vilgotf authored Nov 30, 2024
1 parent e8634ce commit 925106d
Show file tree
Hide file tree
Showing 15 changed files with 30 additions and 22 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ jobs:
- name: Install cargo-minimal-versions
uses: taiki-e/install-action@cargo-minimal-versions

- name: Work around old serde_derive version error
run: cargo add -p twilight-model [email protected]

- name: Check minimal versions
run: cargo minimal-versions check

Expand Down
2 changes: 1 addition & 1 deletion twilight-cache-inmemory/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ impl<K: Eq + Hash, V: Debug> Debug for Reference<'_, K, V> {
}
}

impl<'a, K: Eq + Hash, V> Deref for Reference<'a, K, V> {
impl<K: Eq + Hash, V> Deref for Reference<'_, K, V> {
type Target = V;

fn deref(&self) -> &Self::Target {
Expand Down
4 changes: 2 additions & 2 deletions twilight-gateway/src/stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ mod private {
}
}

impl<'a, St: ?Sized + Stream<Item = Result<Message, ReceiveMessageError>> + Unpin> Future
for NextEvent<'a, St>
impl<St: ?Sized + Stream<Item = Result<Message, ReceiveMessageError>> + Unpin> Future
for NextEvent<'_, St>
{
type Output = Option<Result<Event, ReceiveMessageError>>;

Expand Down
2 changes: 1 addition & 1 deletion twilight-http/src/routing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,7 +1187,7 @@ pub enum Route<'a> {
UpdateCurrentUserApplication,
}

impl<'a> Route<'a> {
impl Route<'_> {
/// HTTP method of the route.
///
/// # Examples
Expand Down
3 changes: 2 additions & 1 deletion twilight-lavalink/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#![allow(
clippy::module_name_repetitions,
clippy::must_use_candidate,
clippy::unnecessary_wraps
clippy::unnecessary_wraps,
clippy::used_underscore_items
)]

pub mod client;
Expand Down
2 changes: 1 addition & 1 deletion twilight-mention/src/parse/iter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ impl<'a, T> MentionIter<'a, T> {
}
}

impl<'a, T: ParseMention> Iterator for MentionIter<'a, T> {
impl<T: ParseMention> Iterator for MentionIter<'_, T> {
/// Found mention followed by the start and ending indexes in the source
/// string returned by [`as_str`].
///
Expand Down
2 changes: 1 addition & 1 deletion twilight-model/src/gateway/event/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl<'a> DispatchEventWithTypeDeserializer<'a> {
}
}

impl<'de, 'a> DeserializeSeed<'de> for DispatchEventWithTypeDeserializer<'a> {
impl<'de> DeserializeSeed<'de> for DispatchEventWithTypeDeserializer<'_> {
type Value = DispatchEvent;

#[allow(clippy::too_many_lines)]
Expand Down
2 changes: 1 addition & 1 deletion twilight-model/src/guild/permissions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ bitflags! {

struct PermissionsVisitor;

impl<'de> Visitor<'de> for PermissionsVisitor {
impl Visitor<'_> for PermissionsVisitor {
type Value = Permissions;

fn expecting(&self, f: &mut Formatter<'_>) -> FmtResult {
Expand Down
3 changes: 2 additions & 1 deletion twilight-model/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
#![allow(
clippy::module_name_repetitions,
clippy::must_use_candidate,
clippy::semicolon_if_nothing_returned
clippy::semicolon_if_nothing_returned,
clippy::used_underscore_items
)]

pub mod application;
Expand Down
2 changes: 1 addition & 1 deletion twilight-model/src/user/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) mod discriminator {

struct DiscriminatorVisitor;

impl<'de> Visitor<'de> for DiscriminatorVisitor {
impl Visitor<'_> for DiscriminatorVisitor {
type Value = u16;

fn expecting(&self, f: &mut Formatter<'_>) -> FmtResult {
Expand Down
2 changes: 1 addition & 1 deletion twilight-model/src/util/hex_color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ impl FromStr for HexColor {

struct HexColorVisitor;

impl<'de> Visitor<'de> for HexColorVisitor {
impl Visitor<'_> for HexColorVisitor {
type Value = HexColor;

fn expecting(&self, formatter: &mut Formatter) -> FmtResult {
Expand Down
2 changes: 1 addition & 1 deletion twilight-model/src/util/mustbe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ impl<'de, const T: bool> Deserialize<'de> for MustBeBool<T> {
{
struct MustBeBoolVisitor(bool);

impl<'de> Visitor<'de> for MustBeBoolVisitor {
impl Visitor<'_> for MustBeBoolVisitor {
type Value = ();

fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
Expand Down
4 changes: 2 additions & 2 deletions twilight-model/src/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ pub mod null_boolean {

struct NullBooleanVisitor;

impl<'de> Visitor<'de> for NullBooleanVisitor {
impl Visitor<'_> for NullBooleanVisitor {
type Value = bool;

fn expecting(&self, f: &mut Formatter<'_>) -> FmtResult {
Expand Down Expand Up @@ -111,7 +111,7 @@ pub mod zeroable_id {

// Clippy will say this bool can be taken by value, but we need it to be
// passed by reference because that's what serde does.
#[allow(clippy::trivially_copy_pass_by_ref)]
#[allow(clippy::ref_option, clippy::trivially_copy_pass_by_ref)]
pub fn serialize<S: Serializer, T>(
value: &Option<Id<T>>,
serializer: S,
Expand Down
3 changes: 2 additions & 1 deletion twilight-util/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
#![allow(
clippy::module_name_repetitions,
clippy::must_use_candidate,
clippy::unnecessary_wraps
clippy::unnecessary_wraps,
clippy::used_underscore_items
)]

#[cfg(feature = "builder")]
Expand Down
16 changes: 9 additions & 7 deletions twilight-validate/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -360,10 +360,10 @@ pub fn command(value: &Command) -> Result<(), CommandValidationError> {
/// Calculate the total character count of a command.
pub fn command_characters(command: &Command) -> usize {
let mut characters =
longest_localization_characters(&command.name, &command.name_localizations)
longest_localization_characters(&command.name, command.name_localizations.as_ref())
+ longest_localization_characters(
&command.description,
&command.description_localizations,
command.description_localizations.as_ref(),
);

for option in &command.options {
Expand All @@ -377,9 +377,11 @@ pub fn command_characters(command: &Command) -> usize {
pub fn option_characters(option: &CommandOption) -> usize {
let mut characters = 0;

characters += longest_localization_characters(&option.name, &option.name_localizations);
characters +=
longest_localization_characters(&option.description, &option.description_localizations);
characters += longest_localization_characters(&option.name, option.name_localizations.as_ref());
characters += longest_localization_characters(
&option.description,
option.description_localizations.as_ref(),
);

match option.kind {
CommandOptionType::String => {
Expand All @@ -388,7 +390,7 @@ pub fn option_characters(option: &CommandOption) -> usize {
if let CommandOptionChoiceValue::String(string_choice) = &choice.value {
characters += longest_localization_characters(
&choice.name,
&choice.name_localizations,
choice.name_localizations.as_ref(),
) + string_choice.len();
}
}
Expand All @@ -415,7 +417,7 @@ pub fn option_characters(option: &CommandOption) -> usize {
/// instead.
fn longest_localization_characters(
default: &str,
localizations: &Option<HashMap<String, String>>,
localizations: Option<&HashMap<String, String>>,
) -> usize {
let mut characters = default.len();

Expand Down

0 comments on commit 925106d

Please sign in to comment.