Remove rust_v_1_46
We just bumped the MSRV to 1.48.0 so we know that we have all features from 1.46, no need for `rust_v_1_46` check anymore.
This commit is contained in:
parent
71fa9e81e7
commit
1dc04fe10f
|
@ -23,7 +23,7 @@ fn main() {
|
||||||
.parse::<u64>()
|
.parse::<u64>()
|
||||||
.expect("invalid Rust minor version");
|
.expect("invalid Rust minor version");
|
||||||
|
|
||||||
for activate_version in &[46, 53, 60] {
|
for activate_version in &[53, 60] {
|
||||||
if minor >= *activate_version {
|
if minor >= *activate_version {
|
||||||
println!("cargo:rustc-cfg=rust_v_1_{}", activate_version);
|
println!("cargo:rustc-cfg=rust_v_1_{}", activate_version);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1953,13 +1953,13 @@ mod tests {
|
||||||
assert_eq!(Amount::from_str("5BTC BTC"), Err(E::InvalidCharacter('B')));
|
assert_eq!(Amount::from_str("5BTC BTC"), Err(E::InvalidCharacter('B')));
|
||||||
assert_eq!(Amount::from_str("5 5 BTC"), Err(E::UnknownDenomination("5 BTC".into())));
|
assert_eq!(Amount::from_str("5 5 BTC"), Err(E::UnknownDenomination("5 BTC".into())));
|
||||||
|
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
fn case(s: &str, expected: Result<Amount, ParseAmountError>) {
|
fn case(s: &str, expected: Result<Amount, ParseAmountError>) {
|
||||||
assert_eq!(Amount::from_str(s), expected);
|
assert_eq!(Amount::from_str(s), expected);
|
||||||
assert_eq!(Amount::from_str(&s.replace(' ', "")), expected);
|
assert_eq!(Amount::from_str(&s.replace(' ', "")), expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
fn scase(s: &str, expected: Result<SignedAmount, ParseAmountError>) {
|
fn scase(s: &str, expected: Result<SignedAmount, ParseAmountError>) {
|
||||||
assert_eq!(SignedAmount::from_str(s), expected);
|
assert_eq!(SignedAmount::from_str(s), expected);
|
||||||
assert_eq!(SignedAmount::from_str(&s.replace(' ', "")), expected);
|
assert_eq!(SignedAmount::from_str(&s.replace(' ', "")), expected);
|
||||||
|
|
|
@ -83,7 +83,7 @@ mod primitive {
|
||||||
type Output = Self;
|
type Output = Self;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
fn index(&self, index: $type) -> &Self::Output {
|
fn index(&self, index: $type) -> &Self::Output {
|
||||||
// Slicing can not make slices longer
|
// Slicing can not make slices longer
|
||||||
unsafe {
|
unsafe {
|
||||||
|
@ -111,7 +111,7 @@ mod primitive {
|
||||||
type Output = u8;
|
type Output = u8;
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
fn index(&self, index: usize) -> &Self::Output { &self.0[index] }
|
fn index(&self, index: usize) -> &Self::Output { &self.0[index] }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ mod primitive {
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
/// This method panics if `index` is out of bounds.
|
/// This method panics if `index` is out of bounds.
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
pub fn remove(&mut self, index: usize) -> u8 { self.0.remove(index) }
|
pub fn remove(&mut self, index: usize) -> u8 { self.0.remove(index) }
|
||||||
|
|
||||||
/// Remove all bytes from buffer without affecting capacity.
|
/// Remove all bytes from buffer without affecting capacity.
|
||||||
|
|
|
@ -1245,8 +1245,13 @@ where
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
crate::internal_macros::maybe_const_fn! {
|
const fn predict_weight_internal(
|
||||||
fn predict_weight_internal(input_count: usize, partial_input_weight: usize, inputs_with_witnesses: usize, output_count: usize, output_scripts_size: usize) -> Weight {
|
input_count: usize,
|
||||||
|
partial_input_weight: usize,
|
||||||
|
inputs_with_witnesses: usize,
|
||||||
|
output_count: usize,
|
||||||
|
output_scripts_size: usize,
|
||||||
|
) -> Weight {
|
||||||
let input_weight = partial_input_weight + input_count * 4 * (32 + 4 + 4);
|
let input_weight = partial_input_weight + input_count * 4 * (32 + 4 + 4);
|
||||||
let output_size = 8 * output_count + output_scripts_size;
|
let output_size = 8 * output_count + output_scripts_size;
|
||||||
let non_input_size =
|
let non_input_size =
|
||||||
|
@ -1264,7 +1269,6 @@ crate::internal_macros::maybe_const_fn! {
|
||||||
non_input_size * 4 + input_weight + input_count - inputs_with_witnesses + 2
|
non_input_size * 4 + input_weight + input_count - inputs_with_witnesses + 2
|
||||||
};
|
};
|
||||||
Weight::from_wu(weight as u64)
|
Weight::from_wu(weight as u64)
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Predicts the weight of a to-be-constructed transaction in const context.
|
/// Predicts the weight of a to-be-constructed transaction in const context.
|
||||||
|
@ -1276,7 +1280,6 @@ crate::internal_macros::maybe_const_fn! {
|
||||||
/// `predict_weight` and thus is intended to be only used in `const` context.
|
/// `predict_weight` and thus is intended to be only used in `const` context.
|
||||||
///
|
///
|
||||||
/// Please see the documentation of `predict_weight` to learn more about this function.
|
/// Please see the documentation of `predict_weight` to learn more about this function.
|
||||||
#[cfg(rust_v_1_46)]
|
|
||||||
pub const fn predict_weight_from_slices(
|
pub const fn predict_weight_from_slices(
|
||||||
inputs: &[InputWeightPrediction],
|
inputs: &[InputWeightPrediction],
|
||||||
output_script_lens: &[usize],
|
output_script_lens: &[usize],
|
||||||
|
@ -1402,7 +1405,6 @@ impl InputWeightPrediction {
|
||||||
/// This is a `const` version of [`new`](Self::new) which only allows slices due to current Rust
|
/// This is a `const` version of [`new`](Self::new) which only allows slices due to current Rust
|
||||||
/// limitations around `const fn`. Because of these limitations it may be less efficient than
|
/// limitations around `const fn`. Because of these limitations it may be less efficient than
|
||||||
/// `new` and thus is intended to be only used in `const` context.
|
/// `new` and thus is intended to be only used in `const` context.
|
||||||
#[cfg(rust_v_1_46)]
|
|
||||||
pub const fn from_slice(input_script_len: usize, witness_element_lengths: &[usize]) -> Self {
|
pub const fn from_slice(input_script_len: usize, witness_element_lengths: &[usize]) -> Self {
|
||||||
let mut i = 0;
|
let mut i = 0;
|
||||||
let mut total_size = 0;
|
let mut total_size = 0;
|
||||||
|
|
|
@ -365,7 +365,6 @@ impl_int_encodable!(i64, read_i64, emit_i64);
|
||||||
|
|
||||||
#[allow(clippy::len_without_is_empty)] // VarInt has on concept of 'is_empty'.
|
#[allow(clippy::len_without_is_empty)] // VarInt has on concept of 'is_empty'.
|
||||||
impl VarInt {
|
impl VarInt {
|
||||||
crate::internal_macros::maybe_const_fn! {
|
|
||||||
/// Gets the length of this VarInt when encoded.
|
/// Gets the length of this VarInt when encoded.
|
||||||
///
|
///
|
||||||
/// *Important: this method is only `const` in Rust 1.46 or higher!*
|
/// *Important: this method is only `const` in Rust 1.46 or higher!*
|
||||||
|
@ -373,13 +372,12 @@ impl VarInt {
|
||||||
/// Returns 1 for 0..=0xFC, 3 for 0xFD..=(2^16-1), 5 for 0x10000..=(2^32-1),
|
/// Returns 1 for 0..=0xFC, 3 for 0xFD..=(2^16-1), 5 for 0x10000..=(2^32-1),
|
||||||
/// and 9 otherwise.
|
/// and 9 otherwise.
|
||||||
#[inline]
|
#[inline]
|
||||||
pub fn len(&self) -> usize {
|
pub const fn len(&self) -> usize {
|
||||||
match self.0 {
|
match self.0 {
|
||||||
0..=0xFC => { 1 }
|
0..=0xFC => 1,
|
||||||
0xFD..=0xFFFF => { 3 }
|
0xFD..=0xFFFF => 3,
|
||||||
0x10000..=0xFFFFFFFF => { 5 }
|
0x10000..=0xFFFFFFFF => 5,
|
||||||
_ => { 9 }
|
_ => 9,
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -213,7 +213,7 @@ impl<W: fmt::Write> ErrorTrackingWriter<W> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
fn assert_no_error(&self, fun: &str) {
|
fn assert_no_error(&self, fun: &str) {
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
{
|
{
|
||||||
|
|
|
@ -45,20 +45,6 @@ macro_rules! impl_consensus_encoding {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
pub(crate) use impl_consensus_encoding;
|
pub(crate) use impl_consensus_encoding;
|
||||||
|
|
||||||
/// Marks the function const in Rust 1.46.0
|
|
||||||
macro_rules! maybe_const_fn {
|
|
||||||
($(#[$attr:meta])* $vis:vis fn $name:ident($($args:tt)*) -> $ret:ty $body:block) => {
|
|
||||||
#[cfg(rust_v_1_46)]
|
|
||||||
$(#[$attr])*
|
|
||||||
$vis const fn $name($($args)*) -> $ret $body
|
|
||||||
|
|
||||||
#[cfg(not(rust_v_1_46))]
|
|
||||||
$(#[$attr])*
|
|
||||||
$vis fn $name($($args)*) -> $ret $body
|
|
||||||
}
|
|
||||||
}
|
|
||||||
pub(crate) use maybe_const_fn;
|
|
||||||
// We use test_macros module to keep things organised, re-export everything for ease of use.
|
// We use test_macros module to keep things organised, re-export everything for ease of use.
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
pub(crate) use test_macros::*;
|
pub(crate) use test_macros::*;
|
||||||
|
|
|
@ -68,7 +68,7 @@ mod out_bytes {
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
/// The method panics if `len` is out of bounds.
|
/// The method panics if `len` is out of bounds.
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
pub(crate) fn assume_init(&self, len: usize) -> &[u8] { &self.0[..len] }
|
pub(crate) fn assume_init(&self, len: usize) -> &[u8] { &self.0[..len] }
|
||||||
|
|
||||||
/// Writes given bytes into the buffer.
|
/// Writes given bytes into the buffer.
|
||||||
|
@ -76,7 +76,7 @@ mod out_bytes {
|
||||||
/// ## Panics
|
/// ## Panics
|
||||||
///
|
///
|
||||||
/// The method panics if pos is out of bounds or `bytes` don't fit into the buffer.
|
/// The method panics if pos is out of bounds or `bytes` don't fit into the buffer.
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
pub(crate) fn write(&mut self, pos: usize, bytes: &[u8]) {
|
pub(crate) fn write(&mut self, pos: usize, bytes: &[u8]) {
|
||||||
self.0[pos..(pos + bytes.len())].copy_from_slice(bytes);
|
self.0[pos..(pos + bytes.len())].copy_from_slice(bytes);
|
||||||
}
|
}
|
||||||
|
@ -193,7 +193,7 @@ impl<T: AsOutBytes> BufEncoder<T> {
|
||||||
///
|
///
|
||||||
/// The method panics if the buffer is full.
|
/// The method panics if the buffer is full.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
pub fn put_byte(&mut self, byte: u8, case: Case) {
|
pub fn put_byte(&mut self, byte: u8, case: Case) {
|
||||||
self.buf.as_mut_out_bytes().write(self.pos, &super::byte_to_hex(byte, case.table()));
|
self.buf.as_mut_out_bytes().write(self.pos, &super::byte_to_hex(byte, case.table()));
|
||||||
self.pos += 2;
|
self.pos += 2;
|
||||||
|
@ -205,7 +205,7 @@ impl<T: AsOutBytes> BufEncoder<T> {
|
||||||
///
|
///
|
||||||
/// The method panics if the bytes wouldn't fit the buffer.
|
/// The method panics if the bytes wouldn't fit the buffer.
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
pub fn put_bytes<I>(&mut self, bytes: I, case: Case)
|
pub fn put_bytes<I>(&mut self, bytes: I, case: Case)
|
||||||
where
|
where
|
||||||
I: IntoIterator,
|
I: IntoIterator,
|
||||||
|
@ -215,7 +215,7 @@ impl<T: AsOutBytes> BufEncoder<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
fn put_bytes_inner<I>(&mut self, bytes: I, case: Case)
|
fn put_bytes_inner<I>(&mut self, bytes: I, case: Case)
|
||||||
where
|
where
|
||||||
I: Iterator,
|
I: Iterator,
|
||||||
|
@ -236,7 +236,7 @@ impl<T: AsOutBytes> BufEncoder<T> {
|
||||||
/// bytes. The method returns an empty slice if all bytes were written
|
/// bytes. The method returns an empty slice if all bytes were written
|
||||||
#[must_use = "this may write only part of the input buffer"]
|
#[must_use = "this may write only part of the input buffer"]
|
||||||
#[inline]
|
#[inline]
|
||||||
#[cfg_attr(rust_v_1_46, track_caller)]
|
#[track_caller]
|
||||||
pub fn put_bytes_min<'a>(&mut self, bytes: &'a [u8], case: Case) -> &'a [u8] {
|
pub fn put_bytes_min<'a>(&mut self, bytes: &'a [u8], case: Case) -> &'a [u8] {
|
||||||
let to_write = self.space_remaining().min(bytes.len());
|
let to_write = self.space_remaining().min(bytes.len());
|
||||||
self.put_bytes(&bytes[..to_write], case);
|
self.put_bytes(&bytes[..to_write], case);
|
||||||
|
|
Loading…
Reference in New Issue