Skip to content

Commit c39ce79

Browse files
committed
Merge #287: clippy: fix uninlined format args
d75126e clippy: allow `uninlined_format_args` (valued mammal) cbf0cfe chore: update rust-version to 1.88.0 (valued mammal) aa53cc1 clippy: fix uninlined format args (valued mammal) Pull request description: Fix #281 by taking clippy's suggestion to inline the arguments to a `format!` string where applicable. Also update `rust-version` to 1.88.0, closing #280. ### Notes to the reviewers I've gone ahead and fixed the clippy warnings, although some have argued that the lint is quite pedantic and not entirely helpful when it comes to style and readability. Therefore I also allowed the lint to prevent clippy from warning about it in the future d75126e. That change can be reverted if/when rust lang moves `uninlined_format_args` back to the pedantic, i.e. not default group of lints rust-lang/rust-clippy#15287. ### Checklists #### All Submissions: * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [ ] ~~This pull request breaks the existing API~~ ACKs for top commit: notmandatory: ACK d75126e oleonardolima: ACK d75126e Tree-SHA512: c34e701fb08f6ada2b0f34c87c93417ca966b021360fa787563f00c6968444028a876bfaf6952cf468f8ad834556b784002d4fc7fd09886fc7420ff1cb6eff9d
2 parents 2692684 + d75126e commit c39ce79

File tree

21 files changed

+75
-101
lines changed

21 files changed

+75
-101
lines changed

examples/example_wallet_electrum/src/main.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ fn main() -> Result<(), anyhow::Error> {
3939

4040
let address = wallet.next_unused_address(KeychainKind::External);
4141
wallet.persist(&mut db)?;
42-
println!("Generated Address: {}", address);
42+
println!("Generated Address: {address}");
4343

4444
let balance = wallet.balance();
4545
println!("Wallet balance before syncing: {}", balance.total());
@@ -56,9 +56,9 @@ fn main() -> Result<(), anyhow::Error> {
5656
let mut once = HashSet::<KeychainKind>::new();
5757
move |k, spk_i, _| {
5858
if once.insert(k) {
59-
print!("\nScanning keychain [{:?}]", k);
59+
print!("\nScanning keychain [{k:?}]");
6060
}
61-
print!(" {:<3}", spk_i);
61+
print!(" {spk_i:<3}");
6262
stdout.flush().expect("must flush");
6363
}
6464
});
@@ -74,10 +74,7 @@ fn main() -> Result<(), anyhow::Error> {
7474
println!("Wallet balance after syncing: {}", balance.total());
7575

7676
if balance.total() < SEND_AMOUNT {
77-
println!(
78-
"Please send at least {} to the receiving address",
79-
SEND_AMOUNT
80-
);
77+
println!("Please send at least {SEND_AMOUNT} to the receiving address");
8178
std::process::exit(0);
8279
}
8380

examples/example_wallet_esplora_async/src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ async fn main() -> Result<(), anyhow::Error> {
5050
let mut once = BTreeSet::<KeychainKind>::new();
5151
move |keychain, spk_i, _| {
5252
if once.insert(keychain) {
53-
print!("\nScanning keychain [{:?}]", keychain);
53+
print!("\nScanning keychain [{keychain:?}]");
5454
}
55-
print!(" {:<3}", spk_i);
55+
print!(" {spk_i:<3}");
5656
stdout.flush().expect("must flush")
5757
}
5858
});
@@ -69,10 +69,7 @@ async fn main() -> Result<(), anyhow::Error> {
6969
println!("Wallet balance after syncing: {}", balance.total());
7070

7171
if balance.total() < SEND_AMOUNT {
72-
println!(
73-
"Please send at least {} to the receiving address",
74-
SEND_AMOUNT
75-
);
72+
println!("Please send at least {SEND_AMOUNT} to the receiving address");
7673
std::process::exit(0);
7774
}
7875

examples/example_wallet_esplora_blocking/src/main.rs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ fn main() -> Result<(), anyhow::Error> {
5252
let mut once = BTreeSet::<KeychainKind>::new();
5353
move |keychain, spk_i, _| {
5454
if once.insert(keychain) {
55-
print!("\nScanning keychain [{:?}] ", keychain);
55+
print!("\nScanning keychain [{keychain:?}] ");
5656
}
57-
print!(" {:<3}", spk_i);
57+
print!(" {spk_i:<3}");
5858
stdout.flush().expect("must flush")
5959
}
6060
});
@@ -69,10 +69,7 @@ fn main() -> Result<(), anyhow::Error> {
6969
println!("Wallet balance after syncing: {}", balance.total());
7070

7171
if balance.total() < SEND_AMOUNT {
72-
println!(
73-
"Please send at least {} to the receiving address",
74-
SEND_AMOUNT
75-
);
72+
println!("Please send at least {SEND_AMOUNT} to the receiving address");
7673
std::process::exit(0);
7774
}
7875

examples/example_wallet_rpc/src/main.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,10 +166,7 @@ fn main() -> anyhow::Result<()> {
166166
wallet.apply_block_connected_to(&block_emission.block, height, connected_to)?;
167167
wallet.persist(&mut db)?;
168168
let elapsed = start_apply_block.elapsed().as_secs_f32();
169-
println!(
170-
"Applied block {} at height {} in {}s",
171-
hash, height, elapsed
172-
);
169+
println!("Applied block {hash} at height {height} in {elapsed}s");
173170
}
174171
Emission::Mempool(event) => {
175172
let start_apply_mempool = Instant::now();

rust-version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.87.0
1+
1.88.0

wallet/examples/compiler.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ fn main() -> Result<(), Box<dyn Error>> {
4545
)"
4646
.replace(&[' ', '\n', '\t'][..], "");
4747

48-
println!("Compiling policy: \n{}", policy_str);
48+
println!("Compiling policy: \n{policy_str}");
4949

5050
// Parse the string as a [`Concrete`] type miniscript policy.
5151
let policy = Concrete::<String>::from_str(&policy_str)?;
@@ -54,7 +54,7 @@ fn main() -> Result<(), Box<dyn Error>> {
5454
// `policy.compile()` returns the resulting miniscript from the policy.
5555
let descriptor = Descriptor::new_wsh(policy.compile()?)?.to_string();
5656

57-
println!("Compiled into Descriptor: \n{}", descriptor);
57+
println!("Compiled into Descriptor: \n{descriptor}");
5858

5959
// Create a new wallet from descriptors
6060
let mut wallet = Wallet::create_single(descriptor)

wallet/examples/mnemonic_to_descriptors.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ fn main() -> Result<(), anyhow::Error> {
4545
descriptor!(tr((mnemonic_with_passphrase, internal_path)))?
4646
.into_wallet_descriptor(&secp, Network::Testnet)?;
4747

48-
println!("tpub external descriptor: {}", external_descriptor);
49-
println!("tpub internal descriptor: {}", internal_descriptor);
48+
println!("tpub external descriptor: {external_descriptor}");
49+
println!("tpub internal descriptor: {internal_descriptor}");
5050
println!(
5151
"tprv external descriptor: {}",
5252
external_descriptor.to_string_with_secret(&ext_keymap)

wallet/examples/policy.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ fn main() -> Result<(), Box<dyn Error>> {
4242
// But they can be used as independent tools also.
4343
let (wallet_desc, keymap) = desc.into_wallet_descriptor(&secp, Network::Testnet)?;
4444

45-
println!("Example Descriptor for policy analysis : {}", wallet_desc);
45+
println!("Example Descriptor for policy analysis : {wallet_desc}");
4646

4747
// Create the signer with the keymap and descriptor.
4848
let signers_container = SignersContainer::build(keymap, &wallet_desc, &secp);
@@ -54,7 +54,7 @@ fn main() -> Result<(), Box<dyn Error>> {
5454
.extract_policy(&signers_container, BuildSatisfaction::None, &secp)?
5555
.expect("We expect a policy");
5656

57-
println!("Derived Policy for the descriptor {:#?}", policy);
57+
println!("Derived Policy for the descriptor {policy:#?}");
5858

5959
Ok(())
6060
}

wallet/src/descriptor/checksum.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,11 +76,11 @@ mod test {
7676
#[test]
7777
fn test_calc_checksum_invalid_character() {
7878
let sparkle_heart = unsafe { core::str::from_utf8_unchecked(&[240, 159, 146, 150]) };
79-
let invalid_desc = format!("wpkh(tprv8ZgxMBicQKsPdpkqS7Eair4YxjcuuvDPNYmKX3sCniCf16tHEVrjjiSXEkFRnUH77yXc6ZcwHHcL{}fjdi5qUvw3VDfgYiH5mNsj5izuiu2N/1/2/*)", sparkle_heart);
79+
let invalid_desc = format!("wpkh(tprv8ZgxMBicQKsPdpkqS7Eair4YxjcuuvDPNYmKX3sCniCf16tHEVrjjiSXEkFRnUH77yXc6ZcwHHcL{sparkle_heart}fjdi5qUvw3VDfgYiH5mNsj5izuiu2N/1/2/*)");
8080

8181
assert_matches!(
8282
calc_checksum(&invalid_desc),
83-
Err(DescriptorError::Miniscript(miniscript::Error::BadDescriptor(e))) if e == format!("Invalid character in checksum: '{}'", sparkle_heart)
83+
Err(DescriptorError::Miniscript(miniscript::Error::BadDescriptor(e))) if e == format!("Invalid character in checksum: '{sparkle_heart}'")
8484
);
8585
}
8686
}

wallet/src/descriptor/error.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,16 @@ impl fmt::Display for Error {
7171
f,
7272
"The descriptor contains multipath keys with invalid number of paths (must have exactly 2 paths for receive and change)"
7373
),
74-
Self::Key(err) => write!(f, "Key error: {}", err),
75-
Self::Policy(err) => write!(f, "Policy error: {}", err),
74+
Self::Key(err) => write!(f, "Key error: {err}"),
75+
Self::Policy(err) => write!(f, "Policy error: {err}"),
7676
Self::InvalidDescriptorCharacter(char) => {
77-
write!(f, "Invalid descriptor character: {}", char)
77+
write!(f, "Invalid descriptor character: {char}")
7878
}
79-
Self::Bip32(err) => write!(f, "BIP32 error: {}", err),
80-
Self::Base58(err) => write!(f, "Base58 error: {}", err),
81-
Self::Pk(err) => write!(f, "Key-related error: {}", err),
82-
Self::Miniscript(err) => write!(f, "Miniscript error: {}", err),
83-
Self::Hex(err) => write!(f, "Hex decoding error: {}", err),
79+
Self::Bip32(err) => write!(f, "BIP32 error: {err}"),
80+
Self::Base58(err) => write!(f, "Base58 error: {err}"),
81+
Self::Pk(err) => write!(f, "Key-related error: {err}"),
82+
Self::Miniscript(err) => write!(f, "Miniscript error: {err}"),
83+
Self::Hex(err) => write!(f, "Hex decoding error: {err}"),
8484
Self::ExternalAndInternalAreTheSame => {
8585
write!(f, "External and internal descriptors are the same")
8686
}

0 commit comments

Comments
 (0)