Skip to content

Commit d2cdeb4

Browse files
committed
clippy: fix all lints
In src/test_utils.rs I changed 'A'..'Z' to 'A'..='Z', which was a legitimate bugfix. The rest of these are just syntax stuff.
1 parent 5ab9096 commit d2cdeb4

File tree

10 files changed

+23
-20
lines changed

10 files changed

+23
-20
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ base64 = ["bitcoin/base64"]
2424
[dependencies]
2525
bech32 = { version = "0.10.0-beta", default-features = false }
2626
bitcoin = { version = "0.31.0", default-features = false }
27-
internals = { package = "bitcoin-internals", version = "0.2.0", default_features = false }
27+
internals = { package = "bitcoin-internals", version = "0.2.0", default-features = false }
2828

2929
# Do NOT use this as a feature! Use the `serde` feature instead.
3030
actual-serde = { package = "serde", version = "1.0.103", optional = true }

bitcoind-tests/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ miniscript = {path = "../"}
1212
bitcoind = { version = "0.34.0" }
1313
actual-rand = { package = "rand", version = "0.8.4"}
1414
secp256k1 = {version = "0.28.0", features = ["rand-std"]}
15-
internals = { package = "bitcoin-internals", version = "0.2.0", default_features = false }
15+
internals = { package = "bitcoin-internals", version = "0.2.0", default-features = false }

clippy.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
msrv = "1.48.0"
22
# plan API returns Self as an error type for an large-ish enum
33
large-error-threshold = 512
4+
# A couple tests have huge tuples instead of structs. This is fixed
5+
# in a later major rev. For now we just turn down the lint.
6+
type-complexity-threshold = 1000

src/descriptor/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1109,7 +1109,7 @@ mod tests {
11091109
.push_opcode(opcodes::all::OP_DUP)
11101110
.push_opcode(opcodes::all::OP_HASH160)
11111111
.push_slice(
1112-
&hash160::Hash::from_str("84e9ed95a38613f0527ff685a9928abe2d4754d4",)
1112+
hash160::Hash::from_str("84e9ed95a38613f0527ff685a9928abe2d4754d4",)
11131113
.unwrap()
11141114
.to_byte_array()
11151115
)
@@ -1133,7 +1133,7 @@ mod tests {
11331133
script::Builder::new()
11341134
.push_opcode(opcodes::all::OP_PUSHBYTES_0)
11351135
.push_slice(
1136-
&hash160::Hash::from_str("84e9ed95a38613f0527ff685a9928abe2d4754d4",)
1136+
hash160::Hash::from_str("84e9ed95a38613f0527ff685a9928abe2d4754d4",)
11371137
.unwrap()
11381138
.to_byte_array()
11391139
)
@@ -1155,7 +1155,7 @@ mod tests {
11551155
script::Builder::new()
11561156
.push_opcode(opcodes::all::OP_HASH160)
11571157
.push_slice(
1158-
&hash160::Hash::from_str("f1c3b9a431134cb90a500ec06e0067cfa9b8bba7",)
1158+
hash160::Hash::from_str("f1c3b9a431134cb90a500ec06e0067cfa9b8bba7",)
11591159
.unwrap()
11601160
.to_byte_array()
11611161
)
@@ -1178,7 +1178,7 @@ mod tests {
11781178
script::Builder::new()
11791179
.push_opcode(opcodes::all::OP_HASH160)
11801180
.push_slice(
1181-
&hash160::Hash::from_str("aa5282151694d3f2f32ace7d00ad38f927a33ac8",)
1181+
hash160::Hash::from_str("aa5282151694d3f2f32ace7d00ad38f927a33ac8",)
11821182
.unwrap()
11831183
.to_byte_array()
11841184
)
@@ -1201,7 +1201,7 @@ mod tests {
12011201
script::Builder::new()
12021202
.push_opcode(opcodes::all::OP_PUSHBYTES_0)
12031203
.push_slice(
1204-
&sha256::Hash::from_str(
1204+
sha256::Hash::from_str(
12051205
"\
12061206
f9379edc8983152dc781747830075bd5\
12071207
3896e4b0ce5bff73777fd77d124ba085\
@@ -1228,7 +1228,7 @@ mod tests {
12281228
script::Builder::new()
12291229
.push_opcode(opcodes::all::OP_HASH160)
12301230
.push_slice(
1231-
&hash160::Hash::from_str("4bec5d7feeed99e1d0a23fe32a4afe126a7ff07e",)
1231+
hash160::Hash::from_str("4bec5d7feeed99e1d0a23fe32a4afe126a7ff07e",)
12321232
.unwrap()
12331233
.to_byte_array()
12341234
)
@@ -1333,7 +1333,7 @@ mod tests {
13331333
let redeem_script = script::Builder::new()
13341334
.push_opcode(opcodes::all::OP_PUSHBYTES_0)
13351335
.push_slice(
1336-
&hash160::Hash::from_str("d1b2a1faf62e73460af885c687dee3b7189cd8ab")
1336+
hash160::Hash::from_str("d1b2a1faf62e73460af885c687dee3b7189cd8ab")
13371337
.unwrap()
13381338
.to_byte_array(),
13391339
)

src/descriptor/tr.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ impl<Pk: MiniscriptKey> TapTree<Pk> {
127127

128128
/// Iterates over all miniscripts in DFS walk order compatible with the
129129
/// PSBT requirements (BIP 371).
130-
pub fn iter(&self) -> TapTreeIter<Pk> { TapTreeIter { stack: vec![(0, self)] } }
130+
pub fn iter(&self) -> TapTreeIter<'_, Pk> { TapTreeIter { stack: vec![(0, self)] } }
131131

132132
// Helper function to translate keys
133133
fn translate_helper<T, Q, E>(&self, t: &mut T) -> Result<TapTree<Q>, TranslateErr<E>>
@@ -194,7 +194,7 @@ impl<Pk: MiniscriptKey> Tr<Pk> {
194194

195195
/// Iterate over all scripts in merkle tree. If there is no script path, the iterator
196196
/// yields [`None`]
197-
pub fn iter_scripts(&self) -> TapTreeIter<Pk> {
197+
pub fn iter_scripts(&self) -> TapTreeIter<'_, Pk> {
198198
match self.tree {
199199
Some(ref t) => t.iter(),
200200
None => TapTreeIter { stack: vec![] },
@@ -560,7 +560,7 @@ impl<Pk: MiniscriptKey> fmt::Display for Tr<Pk> {
560560
}
561561

562562
// Helper function to parse string into miniscript tree form
563-
fn parse_tr_tree(s: &str) -> Result<expression::Tree, Error> {
563+
fn parse_tr_tree(s: &str) -> Result<expression::Tree<'_>, Error> {
564564
expression::check_valid_chars(s)?;
565565

566566
if s.len() > 3 && &s[..3] == "tr(" && s.as_bytes()[s.len() - 1] == b')' {

src/iter/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub use tree::{
1717
use crate::sync::Arc;
1818
use crate::{policy, Miniscript, MiniscriptKey, ScriptContext, Terminal};
1919

20-
impl<'a, Pk: MiniscriptKey, Ctx: ScriptContext> TreeLike for &'a Miniscript<Pk, Ctx> {
20+
impl<Pk: MiniscriptKey, Ctx: ScriptContext> TreeLike for &'_ Miniscript<Pk, Ctx> {
2121
fn as_node(&self) -> Tree<Self> {
2222
use Terminal::*;
2323
match self.node {
@@ -69,7 +69,7 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> TreeLike for Arc<Miniscript<Pk, Ctx>
6969
}
7070
}
7171

72-
impl<'a, Pk: MiniscriptKey> TreeLike for &'a policy::Concrete<Pk> {
72+
impl<Pk: MiniscriptKey> TreeLike for &'_ policy::Concrete<Pk> {
7373
fn as_node(&self) -> Tree<Self> {
7474
use policy::Concrete::*;
7575
match *self {

src/miniscript/iter.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ impl<Pk: MiniscriptKey, Ctx: ScriptContext> Miniscript<Pk, Ctx> {
1818
/// Creates a new [Iter] iterator that will iterate over all [Miniscript] items within
1919
/// AST by traversing its branches. For the specific algorithm please see
2020
/// [Iter::next] function.
21-
pub fn iter(&self) -> Iter<Pk, Ctx> { Iter::new(self) }
21+
pub fn iter(&self) -> Iter<'_, Pk, Ctx> { Iter::new(self) }
2222

2323
/// Creates a new [PkIter] iterator that will iterate over all plain public keys (and not
2424
/// key hash values) present in [Miniscript] items within AST by traversing all its branches.
2525
/// For the specific algorithm please see [PkIter::next] function.
26-
pub fn iter_pk(&self) -> PkIter<Pk, Ctx> { PkIter::new(self) }
26+
pub fn iter_pk(&self) -> PkIter<'_, Pk, Ctx> { PkIter::new(self) }
2727

2828
/// Enumerates all child nodes of the current AST node (`self`) and returns a `Vec` referencing
2929
/// them.

src/miniscript/lex.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ impl<'s> TokenIter<'s> {
7575
pub fn new(v: Vec<Token<'s>>) -> TokenIter<'s> { TokenIter(v) }
7676

7777
/// Look at the top at Iterator
78-
pub fn peek(&self) -> Option<&'s Token> { self.0.last() }
78+
pub fn peek(&self) -> Option<&'s Token<'_>> { self.0.last() }
7979

8080
/// Push a value to the iterator
8181
/// This will be first value consumed by popun_

src/miniscript/satisfy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ impl_satisfier_for_map_hash_tapleafhash_to_key_taproot_sig! {
268268
impl Satisfier<Pk> for HashMap<(hash160::Hash, TapLeafHash), (Pk, bitcoin::taproot::Signature)>
269269
}
270270

271-
impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'a S {
271+
impl<Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'_ S {
272272
fn lookup_ecdsa_sig(&self, p: &Pk) -> Option<bitcoin::ecdsa::Signature> {
273273
(**self).lookup_ecdsa_sig(p)
274274
}
@@ -328,7 +328,7 @@ impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'
328328
fn check_after(&self, n: absolute::LockTime) -> bool { (**self).check_after(n) }
329329
}
330330

331-
impl<'a, Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'a mut S {
331+
impl<Pk: MiniscriptKey + ToPublicKey, S: Satisfier<Pk>> Satisfier<Pk> for &'_ mut S {
332332
fn lookup_ecdsa_sig(&self, p: &Pk) -> Option<bitcoin::ecdsa::Signature> {
333333
(**self).lookup_ecdsa_sig(p)
334334
}

src/test_utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ impl StrXOnlyKeyTranslator {
168168
.collect();
169169
let mut pk_map = HashMap::new();
170170
let mut pkh_map = HashMap::new();
171-
for (i, c) in (b'A'..b'Z').enumerate() {
171+
for (i, c) in (b'A'..=b'Z').enumerate() {
172172
let key = String::from_utf8(vec![c]).unwrap();
173173
pk_map.insert(key.clone(), pks[i]);
174174
pkh_map.insert(key, pks[i].to_pubkeyhash(SigType::Schnorr));

0 commit comments

Comments
 (0)