Merge rust-bitcoin/rust-bitcoin#3214: Panic in const context
60b3cabb41
Panic in const context (Tobin C. Harding) Pull request description: Now that our MSRV is past 1.57 we can panic in const contexts. Fix: #2427 ACKs for top commit: Kixunil: ACK60b3cabb41
apoelstra: ACK60b3cabb41
successfully ran local tests Tree-SHA512: 705a8b7d52a11826e6084684706cb7e01dfaa554e4e369739e64e64263537b0c8c0e518b04e96249ecdeea1f22b534594ffd2a89e17ebba85b369d896e820239
This commit is contained in:
commit
722a7239df
|
@ -188,11 +188,7 @@ impl Midstate {
|
|||
/// Panics if `bytes_hashed` is not a multiple of 64.
|
||||
pub const fn new(state: [u8; 32], bytes_hashed: usize) -> Self {
|
||||
if bytes_hashed % 64 != 0 {
|
||||
// When MSRV is 1.57+ we can use `panic!()`.
|
||||
#[allow(unconditional_panic)]
|
||||
#[allow(clippy::let_unit_value)]
|
||||
#[allow(clippy::out_of_bounds_indexing)]
|
||||
let _panic = [(); 0][1];
|
||||
panic!("bytes hashed is not a multiple of 64");
|
||||
}
|
||||
|
||||
Midstate { bytes: state, length: bytes_hashed }
|
||||
|
|
|
@ -901,14 +901,7 @@ impl Amount {
|
|||
pub const fn from_int_btc(btc: u64) -> Amount {
|
||||
match btc.checked_mul(100_000_000) {
|
||||
Some(amount) => Amount::from_sat(amount),
|
||||
None => {
|
||||
// When MSRV is 1.57+ we can use `panic!()`.
|
||||
#[allow(unconditional_panic)]
|
||||
#[allow(clippy::let_unit_value)]
|
||||
#[allow(clippy::out_of_bounds_indexing)]
|
||||
let _int_overflow_converting_btc_to_sats = [(); 0][1];
|
||||
Amount(0)
|
||||
}
|
||||
None => panic!("checked_mul overflowed"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -65,14 +65,7 @@ impl Weight {
|
|||
pub const fn from_vb_unwrap(vb: u64) -> Weight {
|
||||
match vb.checked_mul(Self::WITNESS_SCALE_FACTOR) {
|
||||
Some(weight) => Weight(weight),
|
||||
None => {
|
||||
// When MSRV is 1.57+ we can use `panic!()`.
|
||||
#[allow(unconditional_panic)]
|
||||
#[allow(clippy::let_unit_value)]
|
||||
#[allow(clippy::out_of_bounds_indexing)]
|
||||
let _int_overflow_scaling_weight = [(); 0][1];
|
||||
Weight(0)
|
||||
}
|
||||
None => panic!("checked_mul overflowed"),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue