Skip to content

Commit bdf50e3

Browse files
committed
Merge #965: Self lint and cleanup
2cc105c ci: enable workspace lint rules (Nick Johnson) 5dcd5fc policy: Remove function local wildcard imports (Tobin C. Harding) 6af27b1 Run the formatter (Tobin C. Harding) 7063e4a Enable use_self lint (Tobin C. Harding) Pull request description: This is Nick's patch from #963 + the `Self` stuff from #944 + a patch on top to remove some of the `use Policy::*` instances. There are some in there still because I can't be bothered right now working out why `Self::` doesn't work everywhere. This is a step in the right direction. ACKs for top commit: apoelstra: ACK 2cc105c; successfully ran local tests Tree-SHA512: e4acaa66acf5a48290e328903e9110916c5ffdd8f45bcbf0a4a77adfdd8401a8749dbc6b7d69076eccaf2823b431fd61951e0e9cf33a6305c9ed073c14b90df6
2 parents c65d220 + 2cc105c commit bdf50e3

44 files changed

Lines changed: 1145 additions & 1244 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.toml

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,11 +70,17 @@ name = "taptree_of_horror"
7070
path = "examples/taptree_of_horror/taptree_of_horror.rs"
7171
required-features = ["compiler"]
7272

73-
[workspace]
74-
members = ["fuzz"]
75-
exclude = ["embedded", "bitcoind-tests"]
76-
7773
[package.metadata.rbmt.lint]
7874
allowed_duplicates = [
7975
"hex-conservative",
8076
]
77+
78+
[lints]
79+
workspace = true
80+
81+
[workspace]
82+
members = ["fuzz"]
83+
exclude = ["embedded", "bitcoind-tests"]
84+
85+
[workspace.lints.clippy]
86+
use_self = "warn"

src/descriptor/bare.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ impl<Pk: FromStrKey> FromTree for Bare<Pk> {
166166
fn from_tree(root: expression::TreeIterItem) -> Result<Self, Error> {
167167
let sub = Miniscript::<Pk, BareCtx>::from_tree(root)?;
168168
BareCtx::top_level_checks(&sub)?;
169-
Bare::new(sub)
169+
Self::new(sub)
170170
}
171171
}
172172

@@ -196,7 +196,7 @@ impl<Pk: MiniscriptKey> Pkh<Pk> {
196196
pub fn new(pk: Pk) -> Result<Self, ScriptContextError> {
197197
// do the top-level checks
198198
match BareCtx::check_pk(&pk) {
199-
Ok(()) => Ok(Pkh { pk }),
199+
Ok(()) => Ok(Self { pk }),
200200
Err(e) => Err(e),
201201
}
202202
}
@@ -353,7 +353,7 @@ impl<Pk: FromStrKey> FromTree for Pkh<Pk> {
353353
let pk = root
354354
.verify_terminal_parent("pkh", "public key")
355355
.map_err(Error::Parse)?;
356-
Pkh::new(pk).map_err(Error::ContextError)
356+
Self::new(pk).map_err(Error::ContextError)
357357
}
358358
}
359359

src/descriptor/checksum.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@ pub enum Error {
6161
impl fmt::Display for Error {
6262
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
6363
match *self {
64-
Error::InvalidCharacter { ch, pos } => {
64+
Self::InvalidCharacter { ch, pos } => {
6565
write!(f, "invalid character '{}' (position {})", ch, pos)
6666
}
67-
Error::InvalidChecksumLength { actual, expected } => {
67+
Self::InvalidChecksumLength { actual, expected } => {
6868
write!(f, "invalid checksum (length {}, expected {})", actual, expected)
6969
}
70-
Error::InvalidChecksum { actual, expected } => {
70+
Self::InvalidChecksum { actual, expected } => {
7171
f.write_str("invalid checksum ")?;
7272
for ch in actual {
7373
ch.fmt(f)?;
@@ -135,13 +135,13 @@ pub struct Engine {
135135
}
136136

137137
impl Default for Engine {
138-
fn default() -> Engine { Engine::new() }
138+
fn default() -> Self { Self::new() }
139139
}
140140

141141
impl Engine {
142142
/// Constructs an engine with no input.
143143
pub fn new() -> Self {
144-
Engine { inner: bech32::primitives::checksum::Engine::new(), cls: 0, clscount: 0 }
144+
Self { inner: bech32::primitives::checksum::Engine::new(), cls: 0, clscount: 0 }
145145
}
146146

147147
/// Inputs some data into the checksum engine.

0 commit comments

Comments
 (0)