Skip to content

Commit e52e027

Browse files
hrxijsdanielh
authored andcommitted
Make clippy happy
Ignore warnings with false positives. Remove unused structs. Implement `Default` for structs with `fn new`.
1 parent 297a99a commit e52e027

7 files changed

Lines changed: 5 additions & 57 deletions

File tree

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ keywords = ["nimiq", "cryptocurrency", "blockchain"]
164164
clippy.large_enum_variant = "allow"
165165
clippy.too_many_arguments = "allow"
166166
clippy.type_complexity = "allow"
167+
clippy.empty_docs = "allow" # false positives: https://github.com/rust-lang/rust-clippy/issues/12377
168+
clippy.assigning_clones = "allow" # false positives: https://github.com/rust-lang/rust-clippy/issues/12709
167169

168170
[workspace.dependencies]
169171
nimiq-account = { path = "primitives/account", default-features = false }

network-libp2p/src/connection_pool/behaviour.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ impl<T: Ord> ConnectionState<T> {
171171

172172
/// Returns whether a connection ID is banned
173173
fn is_banned(&self, id: T) -> bool {
174-
self.banned.get(&id).is_some()
174+
self.banned.contains(&id)
175175
}
176176

177177
/// Marks a connection ID as failed

network-libp2p/src/network_metrics.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ struct TopicLabels {
1818
topic: String,
1919
}
2020

21-
#[derive(Clone, Debug, Hash, PartialEq, Eq, EncodeLabelSet)]
22-
struct RequestIdLabels {
23-
request_id: String,
24-
}
25-
2621
impl Default for NetworkMetrics {
2722
fn default() -> Self {
2823
NetworkMetrics {

network-mock/src/network.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ impl MockNetwork {
392392
}
393393
}
394394

395-
async fn publish_with_name<T: Topic>(
395+
async fn publish_with_name<T>(
396396
&self,
397397
topic_name: String,
398398
item: T::Item,

utils/src/merkle/mod.rs

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -241,40 +241,6 @@ impl<'de, H: HashOutput> Deserialize<'de> for MerklePath<H> {
241241
)
242242
}
243243
}
244-
struct MerklePathNodesVisitor<H: HashOutput> {
245-
left_bits: Vec<u8>,
246-
count: usize,
247-
phantom: PhantomData<H>,
248-
}
249-
250-
impl<'de, H: HashOutput> Visitor<'de> for MerklePathNodesVisitor<H> {
251-
type Value = Vec<MerklePathNode<H>>;
252-
253-
fn expecting(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
254-
write!(f, "a set Merkle Path nodes")
255-
}
256-
257-
fn visit_seq<A>(self, mut seq: A) -> Result<Vec<MerklePathNode<H>>, A::Error>
258-
where
259-
A: SeqAccess<'de>,
260-
{
261-
let mut nodes: Vec<MerklePathNode<H>> = Vec::with_capacity(self.count);
262-
let mut curr = 0usize;
263-
while let Some(hash) = seq.next_element::<H>()? {
264-
nodes.push(MerklePathNode {
265-
left: MerklePath::<H>::decompress(curr, &self.left_bits),
266-
hash,
267-
});
268-
curr += 1;
269-
if curr > self.count {
270-
return Err(A::Error::custom(
271-
"Size mismatch for a set of MerklePath nodes",
272-
));
273-
}
274-
}
275-
Ok(nodes)
276-
}
277-
}
278244

279245
pub type Blake2bMerklePath = MerklePath<Blake2bHash>;
280246

validator/src/aggregation/tendermint/state.rs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -142,22 +142,6 @@ impl MacroState {
142142
}
143143
}
144144

145-
struct State<TValidatorNetwork: ValidatorNetwork + 'static>(
146-
pub u32,
147-
pub TendermintState<TendermintProtocol<TValidatorNetwork>>,
148-
)
149-
where
150-
PubsubId<TValidatorNetwork>: std::fmt::Debug + Unpin;
151-
152-
impl<TValidatorNetwork: ValidatorNetwork + 'static> Clone for State<TValidatorNetwork>
153-
where
154-
PubsubId<TValidatorNetwork>: std::fmt::Debug + Unpin,
155-
{
156-
fn clone(&self) -> Self {
157-
Self(self.0, self.1.clone())
158-
}
159-
}
160-
161145
impl IntoDatabaseValue for MacroState {
162146
fn database_byte_size(&self) -> usize {
163147
self.serialized_size()

zkp/src/verifying_key.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use nimiq_zkp_circuits::metadata::VerifyingKeyMetadata;
88
use nimiq_zkp_primitives::VerifyingData;
99
use once_cell::sync::OnceCell;
1010

11+
#[derive(Default)]
1112
pub struct ZKPVerifyingKey {
1213
cell: OnceCell<VerifyingData>,
1314
}

0 commit comments

Comments
 (0)