Skip to content

Commit 85ba847

Browse files
committed
Merge rust-bitcoin#5105: Fix clippy lints with no-default-features
a4be941 Feature gate unused const (Jamil Lambert, PhD) 5e2eeb8 Fix clippy error: struct is never constructed (Jamil Lambert, PhD) fdce327 Fix explicit lifetime clippy lints (Jamil Lambert, PhD) f38221c Fix lint error: passing a unit value to a function (Jamil Lambert, PhD) Pull request description: In preparation for adding crate specific clippy runs in CI with no-default-features, fix all the current lint errors when running it locally in each crate. There is one clippy error locally in primitives from an unused import (only used with alloc), but it is fixed in rust-bitcoin#4998. ACKs for top commit: apoelstra: ACK a4be941; successfully ran local tests tcharding: ACK a4be941 Tree-SHA512: e5f601213782e7ccceecfbdd022020f830dc321d6e31d522a1b93cf56c15735bccb72f3987d8fc6f633dba7ec8b88369aa65429992d97a3c15883c4622c5fd90
2 parents aa0b02a + a4be941 commit 85ba847

File tree

8 files changed

+17
-7
lines changed

8 files changed

+17
-7
lines changed

benches/chacha20_poly1305/chacha20poly1305.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,8 @@ fn bench_chacha20poly1305(c: &mut Criterion) {
4646
let mut buf = ct.clone();
4747
let cipher = ChaCha20Poly1305::new(key, nonce);
4848
let res = cipher.decrypt(black_box(&mut buf), tag, Some(aad));
49-
black_box(res.unwrap());
49+
res.unwrap();
50+
black_box(());
5051
});
5152
});
5253
}

bitcoin/src/psbt/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -753,7 +753,7 @@ impl<'de> serde::Deserialize<'de> for Psbt {
753753
{
754754
struct Visitor;
755755

756-
impl<'de> serde::de::Visitor<'de> for Visitor {
756+
impl serde::de::Visitor<'_> for Visitor {
757757
type Value = Psbt;
758758

759759
fn expecting(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {

consensus_encoding/src/encode/encoders.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ mod tests {
260260

261261
struct TestBytes<'a>(&'a [u8]);
262262

263-
impl<'a> Encodable for TestBytes<'a> {
263+
impl Encodable for TestBytes<'_> {
264264
type Encoder<'s>
265265
= BytesEncoder<'s>
266266
where

consensus_encoding/tests/encode.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@ use std::io::{Cursor, Write};
88
use consensus_encoding::{ArrayEncoder, BytesEncoder, Encodable, Encoder};
99

1010
// Simple test type that implements Encodable.
11+
#[cfg(feature = "alloc")]
1112
struct TestData(u32);
1213

14+
#[cfg(feature = "alloc")]
1315
impl Encodable for TestData {
1416
type Encoder<'s>
1517
= ArrayEncoder<4>
@@ -22,8 +24,10 @@ impl Encodable for TestData {
2224
}
2325

2426
// Test with a type that creates an empty encoder.
27+
#[cfg(feature = "alloc")]
2528
struct EmptyData;
2629

30+
#[cfg(feature = "alloc")]
2731
impl Encodable for EmptyData {
2832
type Encoder<'s>
2933
= ArrayEncoder<0>

hashes/src/sha256/tests.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ fn hash_unoptimized() {
178178
}
179179

180180
// The midstate of an empty hash engine tagged with "TapLeaf".
181+
#[cfg(feature = "alloc")]
181182
const TAP_LEAF_MIDSTATE: Midstate = Midstate::new(
182183
[
183184
156, 224, 228, 230, 124, 17, 108, 57, 56, 179, 202, 242, 195, 15, 80, 137, 211, 243, 147,

hashes/src/sha256t/mod.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,9 @@ macro_rules! sha256t_tag_constructor {
192192

193193
#[cfg(test)]
194194
mod tests {
195-
use crate::{sha256, sha256t};
195+
use crate::sha256t;
196+
#[cfg(feature = "alloc")]
197+
use crate::sha256;
196198

197199
const TEST_MIDSTATE: [u8; 32] = [
198200
156, 224, 228, 230, 124, 17, 108, 57, 56, 179, 202, 242, 195, 15, 80, 137, 211, 243, 147,
@@ -211,8 +213,10 @@ mod tests {
211213
"ed1382037800c9dd938dd8854f1a8863bcdeb6705069b4b56a66ec22519d5829";
212214

213215
#[derive(Copy, Clone, PartialEq, Eq, PartialOrd, Ord, Default, Hash)]
216+
#[cfg(feature = "alloc")]
214217
pub struct TestHashTag;
215218

219+
#[cfg(feature = "alloc")]
216220
impl sha256t::Tag for TestHashTag {
217221
const MIDSTATE: sha256::Midstate = sha256::Midstate::new(TEST_MIDSTATE, 64);
218222
}

primitives/src/transaction.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ impl<'e> WitnessesEncoder<'e> {
431431
}
432432

433433
#[cfg(feature = "alloc")]
434-
impl<'e> Encoder for WitnessesEncoder<'e> {
434+
impl Encoder for WitnessesEncoder<'_> {
435435
#[inline]
436436
fn current_chunk(&self) -> Option<&[u8]> {
437437
// `advance` sets `cur_enc` to `None` once the slice encoder is completely exhausted.
@@ -628,7 +628,7 @@ impl<'de> Deserialize<'de> for OutPoint {
628628
if deserializer.is_human_readable() {
629629
struct StringVisitor;
630630

631-
impl<'de> de::Visitor<'de> for StringVisitor {
631+
impl de::Visitor<'_> for StringVisitor {
632632
type Value = OutPoint;
633633

634634
fn expecting(&self, formatter: &mut fmt::Formatter) -> fmt::Result {

primitives/src/witness.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ impl Encodable for Witness {
279279
}
280280
}
281281

282-
impl<'a> Encoder for WitnessEncoder<'a> {
282+
impl Encoder for WitnessEncoder<'_> {
283283
#[inline]
284284
fn current_chunk(&self) -> Option<&[u8]> { self.0.current_chunk() }
285285

0 commit comments

Comments
 (0)