Skip to content

clippy: fix uninlined format args #287

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions examples/example_wallet_electrum/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ fn main() -> Result<(), anyhow::Error> {

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

let balance = wallet.balance();
println!("Wallet balance before syncing: {}", balance.total());
Expand All @@ -56,9 +56,9 @@ fn main() -> Result<(), anyhow::Error> {
let mut once = HashSet::<KeychainKind>::new();
move |k, spk_i, _| {
if once.insert(k) {
print!("\nScanning keychain [{:?}]", k);
print!("\nScanning keychain [{k:?}]");
}
print!(" {:<3}", spk_i);
print!(" {spk_i:<3}");
stdout.flush().expect("must flush");
}
});
Expand All @@ -74,10 +74,7 @@ fn main() -> Result<(), anyhow::Error> {
println!("Wallet balance after syncing: {}", balance.total());

if balance.total() < SEND_AMOUNT {
println!(
"Please send at least {} to the receiving address",
SEND_AMOUNT
);
println!("Please send at least {SEND_AMOUNT} to the receiving address");
std::process::exit(0);
}

Expand Down
9 changes: 3 additions & 6 deletions examples/example_wallet_esplora_async/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,9 @@ async fn main() -> Result<(), anyhow::Error> {
let mut once = BTreeSet::<KeychainKind>::new();
move |keychain, spk_i, _| {
if once.insert(keychain) {
print!("\nScanning keychain [{:?}]", keychain);
print!("\nScanning keychain [{keychain:?}]");
}
print!(" {:<3}", spk_i);
print!(" {spk_i:<3}");
stdout.flush().expect("must flush")
}
});
Expand All @@ -69,10 +69,7 @@ async fn main() -> Result<(), anyhow::Error> {
println!("Wallet balance after syncing: {}", balance.total());

if balance.total() < SEND_AMOUNT {
println!(
"Please send at least {} to the receiving address",
SEND_AMOUNT
);
println!("Please send at least {SEND_AMOUNT} to the receiving address");
std::process::exit(0);
}

Expand Down
9 changes: 3 additions & 6 deletions examples/example_wallet_esplora_blocking/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ fn main() -> Result<(), anyhow::Error> {
let mut once = BTreeSet::<KeychainKind>::new();
move |keychain, spk_i, _| {
if once.insert(keychain) {
print!("\nScanning keychain [{:?}] ", keychain);
print!("\nScanning keychain [{keychain:?}] ");
}
print!(" {:<3}", spk_i);
print!(" {spk_i:<3}");
stdout.flush().expect("must flush")
}
});
Expand All @@ -69,10 +69,7 @@ fn main() -> Result<(), anyhow::Error> {
println!("Wallet balance after syncing: {}", balance.total());

if balance.total() < SEND_AMOUNT {
println!(
"Please send at least {} to the receiving address",
SEND_AMOUNT
);
println!("Please send at least {SEND_AMOUNT} to the receiving address");
std::process::exit(0);
}

Expand Down
5 changes: 1 addition & 4 deletions examples/example_wallet_rpc/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ fn main() -> anyhow::Result<()> {
wallet.apply_block_connected_to(&block_emission.block, height, connected_to)?;
wallet.persist(&mut db)?;
let elapsed = start_apply_block.elapsed().as_secs_f32();
println!(
"Applied block {} at height {} in {}s",
hash, height, elapsed
);
println!("Applied block {hash} at height {height} in {elapsed}s");
}
Emission::Mempool(event) => {
let start_apply_mempool = Instant::now();
Expand Down
2 changes: 1 addition & 1 deletion rust-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.87.0
1.88.0
4 changes: 2 additions & 2 deletions wallet/examples/compiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ fn main() -> Result<(), Box<dyn Error>> {
)"
.replace(&[' ', '\n', '\t'][..], "");

println!("Compiling policy: \n{}", policy_str);
println!("Compiling policy: \n{policy_str}");

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

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

// Create a new wallet from descriptors
let mut wallet = Wallet::create_single(descriptor)
Expand Down
4 changes: 2 additions & 2 deletions wallet/examples/mnemonic_to_descriptors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ fn main() -> Result<(), anyhow::Error> {
descriptor!(tr((mnemonic_with_passphrase, internal_path)))?
.into_wallet_descriptor(&secp, Network::Testnet)?;

println!("tpub external descriptor: {}", external_descriptor);
println!("tpub internal descriptor: {}", internal_descriptor);
println!("tpub external descriptor: {external_descriptor}");
println!("tpub internal descriptor: {internal_descriptor}");
println!(
"tprv external descriptor: {}",
external_descriptor.to_string_with_secret(&ext_keymap)
Expand Down
4 changes: 2 additions & 2 deletions wallet/examples/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fn main() -> Result<(), Box<dyn Error>> {
// But they can be used as independent tools also.
let (wallet_desc, keymap) = desc.into_wallet_descriptor(&secp, Network::Testnet)?;

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

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

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

Ok(())
}
4 changes: 2 additions & 2 deletions wallet/src/descriptor/checksum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,11 @@ mod test {
#[test]
fn test_calc_checksum_invalid_character() {
let sparkle_heart = unsafe { core::str::from_utf8_unchecked(&[240, 159, 146, 150]) };
let invalid_desc = format!("wpkh(tprv8ZgxMBicQKsPdpkqS7Eair4YxjcuuvDPNYmKX3sCniCf16tHEVrjjiSXEkFRnUH77yXc6ZcwHHcL{}fjdi5qUvw3VDfgYiH5mNsj5izuiu2N/1/2/*)", sparkle_heart);
let invalid_desc = format!("wpkh(tprv8ZgxMBicQKsPdpkqS7Eair4YxjcuuvDPNYmKX3sCniCf16tHEVrjjiSXEkFRnUH77yXc6ZcwHHcL{sparkle_heart}fjdi5qUvw3VDfgYiH5mNsj5izuiu2N/1/2/*)");

assert_matches!(
calc_checksum(&invalid_desc),
Err(DescriptorError::Miniscript(miniscript::Error::BadDescriptor(e))) if e == format!("Invalid character in checksum: '{}'", sparkle_heart)
Err(DescriptorError::Miniscript(miniscript::Error::BadDescriptor(e))) if e == format!("Invalid character in checksum: '{sparkle_heart}'")
);
}
}
16 changes: 8 additions & 8 deletions wallet/src/descriptor/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,16 @@ impl fmt::Display for Error {
f,
"The descriptor contains multipath keys, which are not supported yet"
),
Self::Key(err) => write!(f, "Key error: {}", err),
Self::Policy(err) => write!(f, "Policy error: {}", err),
Self::Key(err) => write!(f, "Key error: {err}"),
Self::Policy(err) => write!(f, "Policy error: {err}"),
Self::InvalidDescriptorCharacter(char) => {
write!(f, "Invalid descriptor character: {}", char)
write!(f, "Invalid descriptor character: {char}")
}
Self::Bip32(err) => write!(f, "BIP32 error: {}", err),
Self::Base58(err) => write!(f, "Base58 error: {}", err),
Self::Pk(err) => write!(f, "Key-related error: {}", err),
Self::Miniscript(err) => write!(f, "Miniscript error: {}", err),
Self::Hex(err) => write!(f, "Hex decoding error: {}", err),
Self::Bip32(err) => write!(f, "BIP32 error: {err}"),
Self::Base58(err) => write!(f, "Base58 error: {err}"),
Self::Pk(err) => write!(f, "Key-related error: {err}"),
Self::Miniscript(err) => write!(f, "Miniscript error: {err}"),
Self::Hex(err) => write!(f, "Hex decoding error: {err}"),
Self::ExternalAndInternalAreTheSame => {
write!(f, "External and internal descriptors are the same")
}
Expand Down
6 changes: 3 additions & 3 deletions wallet/src/descriptor/policy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ where
{
let mut map = serializer.serialize_map(Some(input_map.len()))?;
for (k, v) in input_map {
let k_string = format!("{:?}", k);
let k_string = format!("{k:?}");
map.serialize_entry(&k_string, v)?;
}
map.end()
Expand Down Expand Up @@ -529,8 +529,8 @@ pub enum PolicyError {
impl fmt::Display for PolicyError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::NotEnoughItemsSelected(err) => write!(f, "Not enough items selected: {}", err),
Self::IndexOutOfRange(index) => write!(f, "Index out of range: {}", index),
Self::NotEnoughItemsSelected(err) => write!(f, "Not enough items selected: {err}"),
Self::IndexOutOfRange(index) => write!(f, "Index out of range: {index}"),
Self::AddOnLeaf => write!(f, "Add on leaf"),
Self::AddOnPartialComplete => write!(f, "Add on partial complete"),
Self::MixedTimelockUnits => write!(f, "Mixed timelock units"),
Expand Down
6 changes: 3 additions & 3 deletions wallet/src/keys/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -989,9 +989,9 @@ impl fmt::Display for KeyError {
Self::InvalidScriptContext => write!(f, "Invalid script context"),
Self::InvalidNetwork => write!(f, "Invalid network"),
Self::InvalidChecksum => write!(f, "Invalid checksum"),
Self::Message(err) => write!(f, "{}", err),
Self::Bip32(err) => write!(f, "BIP32 error: {}", err),
Self::Miniscript(err) => write!(f, "Miniscript error: {}", err),
Self::Message(err) => write!(f, "{err}"),
Self::Bip32(err) => write!(f, "BIP32 error: {err}"),
Self::Miniscript(err) => write!(f, "Miniscript error: {err}"),
}
}
}
Expand Down
1 change: 1 addition & 0 deletions wallet/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
)]
#![no_std]
#![warn(missing_docs)]
#![allow(clippy::uninlined_format_args)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't mind leaving this lint enabled even if it's a bit pedantic. But no strong feelings about it either way so OK to allow for now.


#[cfg(feature = "std")]
#[macro_use]
Expand Down
12 changes: 4 additions & 8 deletions wallet/src/wallet/coin_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,7 @@ mod test {
fn foreign_utxo(value: Amount, index: u32) -> WeightedUtxo {
assert!(index < 10);
let outpoint = OutPoint::from_str(&format!(
"000000000000000000000000000000000000000000000000000000000000000{}:0",
index
"000000000000000000000000000000000000000000000000000000000000000{index}:0"
))
.unwrap();
WeightedUtxo {
Expand All @@ -811,8 +810,7 @@ mod test {
) -> WeightedUtxo {
assert!(index < 10);
let outpoint = OutPoint::from_str(&format!(
"000000000000000000000000000000000000000000000000000000000000000{}:0",
index
"000000000000000000000000000000000000000000000000000000000000000{index}:0"
))
.unwrap();
WeightedUtxo {
Expand Down Expand Up @@ -854,8 +852,7 @@ mod test {
satisfaction_weight: Weight::from_wu_usize(P2WPKH_SATISFACTION_SIZE),
utxo: Utxo::Local(LocalOutput {
outpoint: OutPoint::from_str(&format!(
"ebd9813ecebc57ff8f30797de7c205e3c7498ca950ea4341ee51a685ff2fa30a:{}",
i
"ebd9813ecebc57ff8f30797de7c205e3c7498ca950ea4341ee51a685ff2fa30a:{i}"
))
.unwrap(),
txout: TxOut {
Expand Down Expand Up @@ -894,8 +891,7 @@ mod test {
satisfaction_weight: Weight::from_wu_usize(P2WPKH_SATISFACTION_SIZE),
utxo: Utxo::Local(LocalOutput {
outpoint: OutPoint::from_str(&format!(
"ebd9813ecebc57ff8f30797de7c205e3c7498ca950ea4341ee51a685ff2fa30a:{}",
i
"ebd9813ecebc57ff8f30797de7c205e3c7498ca950ea4341ee51a685ff2fa30a:{i}"
))
.unwrap(),
txout: TxOut {
Expand Down
30 changes: 14 additions & 16 deletions wallet/src/wallet/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ pub enum MiniscriptPsbtError {
impl fmt::Display for MiniscriptPsbtError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::Conversion(err) => write!(f, "Conversion error: {}", err),
Self::UtxoUpdate(err) => write!(f, "UTXO update error: {}", err),
Self::OutputUpdate(err) => write!(f, "Output update error: {}", err),
Self::Conversion(err) => write!(f, "Conversion error: {err}"),
Self::UtxoUpdate(err) => write!(f, "UTXO update error: {err}"),
Self::OutputUpdate(err) => write!(f, "Output update error: {err}"),
}
}
}
Expand Down Expand Up @@ -112,7 +112,7 @@ impl fmt::Display for CreateTxError {
Self::Descriptor(e) => e.fmt(f),
Self::Policy(e) => e.fmt(f),
CreateTxError::SpendingPolicyRequired(keychain_kind) => {
write!(f, "Spending policy required: {}", keychain_kind)
write!(f, "Spending policy required: {keychain_kind}")
}
CreateTxError::Version0 => {
write!(f, "Invalid version `0`")
Expand All @@ -127,13 +127,12 @@ impl fmt::Display for CreateTxError {
requested,
required,
} => {
write!(f, "TxBuilder requested timelock of `{}`, but at least `{}` is required to spend from this script", requested, required)
write!(f, "TxBuilder requested timelock of `{requested}`, but at least `{required}` is required to spend from this script")
}
CreateTxError::RbfSequenceCsv { sequence, csv } => {
write!(
f,
"Cannot enable RBF with nSequence `{}` given a required OP_CSV of `{}`",
sequence, csv
"Cannot enable RBF with nSequence `{sequence}` given a required OP_CSV of `{csv}`"
)
}
CreateTxError::FeeTooLow { required } => {
Expand All @@ -152,24 +151,24 @@ impl fmt::Display for CreateTxError {
write!(f, "No UTXO selected")
}
CreateTxError::OutputBelowDustLimit(limit) => {
write!(f, "Output below the dust limit: {}", limit)
write!(f, "Output below the dust limit: {limit}")
}
CreateTxError::CoinSelection(e) => e.fmt(f),
CreateTxError::NoRecipients => {
write!(f, "Cannot build tx without recipients")
}
CreateTxError::Psbt(e) => e.fmt(f),
CreateTxError::MissingKeyOrigin(err) => {
write!(f, "Missing key origin: {}", err)
write!(f, "Missing key origin: {err}")
}
CreateTxError::UnknownUtxo => {
write!(f, "UTXO not found in the internal database")
}
CreateTxError::MissingNonWitnessUtxo(outpoint) => {
write!(f, "Missing non_witness_utxo on foreign utxo {}", outpoint)
write!(f, "Missing non_witness_utxo on foreign utxo {outpoint}")
}
CreateTxError::MiniscriptPsbt(err) => {
write!(f, "Miniscript PSBT error: {}", err)
write!(f, "Miniscript PSBT error: {err}")
}
}
}
Expand Down Expand Up @@ -238,19 +237,18 @@ impl fmt::Display for BuildFeeBumpError {
Self::TransactionNotFound(txid) => {
write!(
f,
"Transaction not found in the internal database with txid: {}",
txid
"Transaction not found in the internal database with txid: {txid}"
)
}
Self::TransactionConfirmed(txid) => {
write!(f, "Transaction already confirmed with txid: {}", txid)
write!(f, "Transaction already confirmed with txid: {txid}")
}
Self::IrreplaceableTransaction(txid) => {
write!(f, "Transaction can't be replaced with txid: {}", txid)
write!(f, "Transaction can't be replaced with txid: {txid}")
}
Self::FeeRateUnavailable => write!(f, "Fee rate unavailable"),
Self::InvalidOutputIndex(op) => {
write!(f, "A txin referenced an invalid output: {}", op)
write!(f, "A txin referenced an invalid output: {op}")
}
}
}
Expand Down
12 changes: 3 additions & 9 deletions wallet/src/wallet/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,17 +237,12 @@ impl fmt::Display for LoadMismatch {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
LoadMismatch::Network { loaded, expected } => {
write!(
f,
"Network mismatch: loaded {}, expected {}",
loaded, expected
)
write!(f, "Network mismatch: loaded {loaded}, expected {expected}")
}
LoadMismatch::Genesis { loaded, expected } => {
write!(
f,
"Genesis hash mismatch: loaded {}, expected {}",
loaded, expected
"Genesis hash mismatch: loaded {loaded}, expected {expected}"
)
}
LoadMismatch::Descriptor {
Expand Down Expand Up @@ -306,8 +301,7 @@ impl fmt::Display for ApplyBlockError {
connected_to_hash: checkpoint_hash,
} => write!(
f,
"`connected_to` hash {} differs from the expected hash {} (which is derived from `block`)",
checkpoint_hash, block_hash
"`connected_to` hash {checkpoint_hash} differs from the expected hash {block_hash} (which is derived from `block`)"
),
}
}
Expand Down
Loading
Loading