Skip to content

Commit 5fceff6

Browse files
author
ChallengeDev210
committed
Merge rust-bitcoin/rust-bitcoin#952: Remove MSRV todo comments
831b026 Use contains() instead of manual range (Tobin C. Harding) 6410095 Use chunks_exact (Tobin C. Harding) 3a0097b Use trim_start_matches (Tobin C. Harding) 0a19710 Use vec! macro instead of new followed by push (Tobin C. Harding) Pull request description: Now that 0.28 is out we do not need to support Rust 1.29 on `master`. Remove trivial MSRV `TODO`s from the code. (All these changes only rely on MSRV bumping to 1.31 so are easily within bounds.) ACKs for top commit: Kixunil: ACK 831b026 sanket1729: ACK 831b026 Tree-SHA512: f1ea594216ba7dfa24696b964ce296a8aea72dd2e16e11d3a43fe8b90c851abf59b1612b2b1311146e8070112f3834762584e4f0515b8f546f72af169eb4bda9
2 parents 4166901 + c504957 commit 5fceff6

File tree

4 files changed

+8
-14
lines changed

4 files changed

+8
-14
lines changed

src/blockdata/opcodes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -651,7 +651,7 @@ impl fmt::Debug for All {
651651
all::OP_CHECKMULTISIGVERIFY => write!(f, "CHECKMULTISIGVERIFY"),
652652
all::OP_CLTV => write!(f, "CLTV"),
653653
all::OP_CSV => write!(f, "CSV"),
654-
All {code: x} if x >= all::OP_NOP1.code && x <= all::OP_NOP10.code => write!(f, "NOP{}", x - all::OP_NOP1.code + 1),
654+
All {code: x} if (all::OP_NOP1.code..=all::OP_NOP10.code).contains(&x) => write!(f, "NOP{}", x - all::OP_NOP1.code + 1),
655655
all::OP_INVALIDOPCODE => write!(f, "INVALIDOPCODE"),
656656
all::OP_CHECKSIGADD => write!(f, "CHECKSIGADD"),
657657
All {code: x} => write!(f, "RETURN_{}", x),

src/blockdata/transaction.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,18 +1208,13 @@ mod tests {
12081208
#[test]
12091209
fn sighash_single_bug() {
12101210
const SIGHASH_SINGLE: u32 = 3;
1211-
// We need a tx with more inputs than outputs.
1212-
let mut input = Vec::new();
1213-
input.push(TxIn::default());
1214-
input.push(TxIn::default());
1215-
let mut output = Vec::new();
1216-
output.push(TxOut::default());
12171211

1212+
// We need a tx with more inputs than outputs.
12181213
let tx = Transaction {
12191214
version: 1,
12201215
lock_time: 0,
1221-
input: input,
1222-
output: output, // TODO: Use Vec::from([TxOut]) once we bump MSRV.
1216+
input: vec![TxIn::default(), TxIn::default()],
1217+
output: vec![TxOut::default()],
12231218
};
12241219
let script = Script::new();
12251220
let got = tx.signature_hash(1, &script, SIGHASH_SINGLE);

src/util/psbt/map/input.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,6 @@ impl fmt::Display for PsbtSighashType {
166166
}
167167
}
168168

169-
#[allow(deprecated)] // TODO: Swap `trim_left_matches` for `trim_start_matches` once MSRV >= 1.30.
170169
impl FromStr for PsbtSighashType {
171170
type Err = SighashTypeParseError;
172171

@@ -184,7 +183,7 @@ impl FromStr for PsbtSighashType {
184183
}
185184

186185
// We accept non-standard sighash values.
187-
if let Ok(inner) = u32::from_str_radix(s.trim_left_matches("0x"), 16) {
186+
if let Ok(inner) = u32::from_str_radix(s.trim_start_matches("0x"), 16) {
188187
return Ok(PsbtSighashType { inner });
189188
}
190189

src/util/taproot.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -683,13 +683,13 @@ impl TaprootMerkleBranch {
683683
Err(TaprootError::InvalidMerkleTreeDepth(sl.len() / TAPROOT_CONTROL_NODE_SIZE))
684684
} else {
685685
let inner = sl
686-
// TODO: Use chunks_exact after MSRV changes to 1.31
687-
.chunks(TAPROOT_CONTROL_NODE_SIZE)
686+
.chunks_exact(TAPROOT_CONTROL_NODE_SIZE)
688687
.map(|chunk| {
689688
sha256::Hash::from_slice(chunk)
690-
.expect("chunk exact always returns the correct size")
689+
.expect("chunks_exact always returns the correct size")
691690
})
692691
.collect();
692+
693693
Ok(TaprootMerkleBranch(inner))
694694
}
695695
}

0 commit comments

Comments
 (0)