Panic in const context
Now that our MSRV is past 1.57 we can panic in const contexts. Fix: #2427
This commit is contained in:
parent
44a2fbb5be
commit
60b3cabb41
|
@ -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