Skip to content

Commit

Permalink
fix: fixed linting warnings for Rust 1.78 stable, 1.80 nightly (#295)
Browse files Browse the repository at this point in the history
  • Loading branch information
dj8yfo authored May 30, 2024
1 parent 6fa3057 commit fa6225c
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 18 deletions.
2 changes: 1 addition & 1 deletion borsh-derive/src/internals/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ impl FindTyParams {
params.push(param.clone());
params_set.insert(param.clone());
}
if associated_type_params_usage.get(param).is_some() && !params_set.contains(param) {
if associated_type_params_usage.contains_key(param) && !params_set.contains(param) {
params.push(param.clone());
params_set.insert(param.clone());
}
Expand Down
17 changes: 10 additions & 7 deletions borsh-derive/src/internals/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,20 @@ fn filter_used_params(generics: &Generics, not_skipped_type_params: HashSet<Iden
let new_predicates: Punctuated<WherePredicate, Comma> = clause
.predicates
.iter()
.filter(|predicate| match predicate {
WherePredicate::Lifetime(..) => true,
WherePredicate::Type(predicate_type) => generics::type_contains_some_param(
&predicate_type.bounded_ty,
&not_skipped_type_params,
),
.filter(|predicate| {
#[cfg_attr(
feature = "force_exhaustive_checks",
deny(non_exhaustive_omitted_patterns)
)]
_ => true,
match predicate {
WherePredicate::Lifetime(..) => true,
WherePredicate::Type(predicate_type) => generics::type_contains_some_param(
&predicate_type.bounded_ty,
&not_skipped_type_params,
),

_ => true,
}
})
.cloned()
.collect();
Expand Down
2 changes: 1 addition & 1 deletion borsh/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ path = "src/generate_schema_schema.rs"
required-features = ["std", "unstable__schema"]

[build-dependencies]
cfg_aliases = "0.1.0"
cfg_aliases = "0.2.1"

[dependencies]
ascii = { version = "1.1", optional = true }
Expand Down
6 changes: 3 additions & 3 deletions borsh/src/de/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -487,11 +487,11 @@ where
}

/// Module is available if borsh is built with `features = ["std"]` or `features = ["hashbrown"]`.
///
/// Module defines [BorshDeserialize] implementation for
/// [HashMap](std::collections::HashMap)/[HashSet](std::collections::HashSet).
#[cfg(hash_collections)]
pub mod hashes {
//!
//! Module defines [BorshDeserialize] implementation for
//! [HashMap](std::collections::HashMap)/[HashSet](std::collections::HashSet).
use core::hash::{BuildHasher, Hash};

use crate::BorshDeserialize;
Expand Down
6 changes: 3 additions & 3 deletions borsh/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,11 +682,11 @@ where
}

/// Module is available if borsh is built with `features = ["std"]` or `features = ["hashbrown"]`.
///
/// Module defines [BorshSchema] implementation for
/// [HashMap](std::collections::HashMap)/[HashSet](std::collections::HashSet).
#[cfg(hash_collections)]
pub mod hashes {
//!
//! Module defines [BorshSchema] implementation for
//! [HashMap](std::collections::HashMap)/[HashSet](std::collections::HashSet).
use crate::BorshSchema;

use super::{add_definition, Declaration, Definition};
Expand Down
6 changes: 3 additions & 3 deletions borsh/src/ser/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -353,11 +353,11 @@ where
}

/// Module is available if borsh is built with `features = ["std"]` or `features = ["hashbrown"]`.
///
/// Module defines [BorshSerialize] implementation for
/// [HashMap](std::collections::HashMap)/[HashSet](std::collections::HashSet).
#[cfg(hash_collections)]
pub mod hashes {
//!
//! Module defines [BorshSerialize] implementation for
//! [HashMap](std::collections::HashMap)/[HashSet](std::collections::HashSet).
use crate::__private::maybestd::vec::Vec;
use crate::error::check_zst;
use crate::{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ fn test_generic_struct() {

trait TraitName {
type Associated;
#[allow(unused)]
fn method(&self);
}

Expand Down
2 changes: 2 additions & 0 deletions borsh/tests/schema/test_generic_enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ fn common_map_associated() -> BTreeMap<String, Definition> {
pub fn generic_associated_item1() {
trait TraitName {
type Associated;
#[allow(unused)]
fn method(&self);
}

Expand Down Expand Up @@ -238,6 +239,7 @@ pub fn generic_associated_item1() {
pub fn generic_associated_item2() {
trait TraitName {
type Associated;
#[allow(unused)]
fn method(&self);
}

Expand Down
3 changes: 3 additions & 0 deletions borsh/tests/schema/test_generic_structs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ fn common_map_associated() -> BTreeMap<String, Definition> {
pub fn generic_associated_item() {
trait TraitName {
type Associated;
#[allow(unused)]
fn method(&self);
}

Expand Down Expand Up @@ -144,6 +145,7 @@ pub fn generic_associated_item() {
pub fn generic_associated_item2() {
trait TraitName {
type Associated;
#[allow(unused)]
fn method(&self);
}

Expand Down Expand Up @@ -177,6 +179,7 @@ pub fn generic_associated_item2() {
pub fn generic_associated_item3() {
trait TraitName {
type Associated;
#[allow(unused)]
fn method(&self);
}

Expand Down

0 comments on commit fa6225c

Please sign in to comment.