clippy: more worning fixes

error[E0308]: mismatched types
  --> bitcoin/src/psbt/raw.rs:87:24
   |
87 |               return Err(encode::Error::OversizedVectorAllocation {
   |  ________________________^
88 | |                 requested: key_byte_size as usize,
89 | |                 max: MAX_VEC_SIZE,
90 | |             });
   | |_____________^ expected enum `psbt::error::Error`, found enum `consensus::encode::Error`
   |
help: try wrapping the expression in `psbt::error::Error::ConsensusEncoding`
   |
87 ~             return Err(psbt::error::Error::ConsensusEncoding(encode::Error::OversizedVectorAllocation {
88 |                 requested: key_byte_size as usize,
89 |                 max: MAX_VEC_SIZE,
90 ~             }));
   |

----

  Compiling bitcoin v0.30.0 (/home/vincent/github/work/rust-btc/rust-bitcoin/bitcoin)
    Checking bitcoin-fuzz v0.0.1 (/home/vincent/github/work/rust-btc/rust-bitcoin/fuzz)
error: redundant clone
   --> bitcoin/examples/taproot-psbt.rs:453:77
    |
453 |             witness_utxo: { Some(TxOut { value, script_pubkey: script_pubkey.clone() }) },
    |                                                                             ^^^^^^^^ help: remove this
    |
    = note: `-D clippy::redundant-clone` implied by `-D warnings`
note: this value is dropped without further use
   --> bitcoin/examples/taproot-psbt.rs:453:64
    |
453 |             witness_utxo: { Some(TxOut { value, script_pubkey: script_pubkey.clone() }) },
    |                                                                ^^^^^^^^^^^^^
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone

error: could not compile `bitcoin` due to previous error
warning: build failed, waiting for other jobs to finish...
error: redundant clone
    --> bitcoin/src/psbt/mod.rs:1095:13
     |
1095 |             .clone()
     |             ^^^^^^^^ help: remove this
     |
     = note: `-D clippy::redundant-clone` implied by `-D warnings`
note: this value is dropped without further use
    --> bitcoin/src/psbt/mod.rs:1094:17
     |
1094 |           assert!(psbt
     |  _________________^
1095 | |             .clone()
     | |____________^
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_clone

Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
This commit is contained in:
Vincenzo Palazzo 2023-10-07 11:36:31 +02:00
parent 05d3dc5d72
commit 98513ef151
No known key found for this signature in database
GPG Key ID: 8B6DC2B870B80D5F
4 changed files with 4 additions and 7 deletions

View File

@ -450,10 +450,7 @@ impl BenefactorWallet {
); );
let input = Input { let input = Input {
witness_utxo: { witness_utxo: { Some(TxOut { value, script_pubkey }) },
let script_pubkey = script_pubkey;
Some(TxOut { value, script_pubkey })
},
tap_key_origins: origins, tap_key_origins: origins,
tap_merkle_root: taproot_spend_info.merkle_root(), tap_merkle_root: taproot_spend_info.merkle_root(),
sighash_type: Some(ty), sighash_type: Some(ty),

View File

@ -1092,7 +1092,6 @@ mod tests {
Err(FeeRate::from_sat_per_kwu(15060240960843)) Err(FeeRate::from_sat_per_kwu(15060240960843))
); );
assert!(psbt assert!(psbt
.clone()
.extract_tx_with_fee_rate_limit(FeeRate::from_sat_per_kwu(15060240960843)) .extract_tx_with_fee_rate_limit(FeeRate::from_sat_per_kwu(15060240960843))
.is_ok()); .is_ok());

View File

@ -87,7 +87,8 @@ impl Key {
return Err(encode::Error::OversizedVectorAllocation { return Err(encode::Error::OversizedVectorAllocation {
requested: key_byte_size as usize, requested: key_byte_size as usize,
max: MAX_VEC_SIZE, max: MAX_VEC_SIZE,
})?; }
.into());
} }
let type_value: u8 = Decodable::consensus_decode(r)?; let type_value: u8 = Decodable::consensus_decode(r)?;

View File

@ -210,7 +210,7 @@ impl Deserialize for KeySource {
while !d.is_empty() { while !d.is_empty() {
match u32::consensus_decode(&mut d) { match u32::consensus_decode(&mut d) {
Ok(index) => dpath.push(index.into()), Ok(index) => dpath.push(index.into()),
Err(e) => return Err(e)?, Err(e) => return Err(e.into()),
} }
} }