From f67aed0078494efbffc22dc0c09009b8d5f10947 Mon Sep 17 00:00:00 2001 From: Trevor Spiteri Date: Sat, 18 Apr 2020 02:21:17 +0200 Subject: [PATCH] remove deprecated items --- .gitlab-ci.yml | 2 +- README.md | 4 + RELEASES.md | 5 + src/cast.rs | 254 ++---------------------------------------- src/macros_frac.rs | 36 ------ src/macros_no_frac.rs | 14 --- src/traits.rs | 56 ---------- src/wrapping.rs | 28 ----- 8 files changed, 20 insertions(+), 379 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index bff7991..59fd0e7 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -89,7 +89,7 @@ x86_64-gnulinux-tarpaulin: image: amd64/rust:1 variables: TARGET: x86_64 - REQ_COVERAGE: "86.2" + REQ_COVERAGE: "87.9" cache: key: $CI_JOB_NAME paths: diff --git a/README.md b/README.md index b675713..6c11598 100644 --- a/README.md +++ b/README.md @@ -74,6 +74,10 @@ The conversions supported cover the following cases. ## What’s new +### Version 1.0.0 news (unreleased) + + * All deprecated items were removed. + ### Version 0.5.5 news (2020-04-16) * Bug fix: an incorrect result could be given when comparing a diff --git a/RELEASES.md b/RELEASES.md index eed9f33..3e48a5e 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -5,6 +5,11 @@ modification, are permitted in any medium without royalty provided the copyright notice and this notice are preserved. This file is offered as-is, without any warranty. --> +Version 1.0.0 (unreleased) +========================== + + * All deprecated items were removed. + Version 0.5.5 (2020-04-16) ========================== diff --git a/src/cast.rs b/src/cast.rs index 0eced4e..1ccd212 100644 --- a/src/cast.rs +++ b/src/cast.rs @@ -18,14 +18,11 @@ use crate::{ FixedI128, FixedI16, FixedI32, FixedI64, FixedI8, FixedU128, FixedU16, FixedU32, FixedU64, FixedU8, }; -#[allow(deprecated)] -use az::StaticCast; use az::{Cast, CheckedCast, OverflowingCast, SaturatingCast, WrappingCast}; -use core::mem; #[cfg(feature = "f16")] use half::{bf16, f16}; -macro_rules! run_time { +macro_rules! cast { ($Src:ident($LeEqUSrc:ident); $Dst:ident($LeEqUDst:ident)) => { impl Cast<$Dst> for $Src { #[inline] @@ -142,269 +139,38 @@ macro_rules! run_time { }; } -macro_rules! compile_time { - ( - impl<$FracSrc:ident: $LeEqUSrc:ident, $FracDst:ident: $LeEqUDst:ident> StaticCast<$Dst:ty> - for $Src:ty - { - $cond:expr - } - ) => { - #[deprecated(since = "0.5.6", note = "deprecated in az crate")] - #[allow(deprecated)] - ///
Deprecated since 0.5.6: - ///

deprecated in az crate since 0.3.1; use case is unclear

- impl<$FracSrc: $LeEqUSrc, $FracDst: $LeEqUDst> StaticCast<$Dst> for $Src { - #[inline] - fn static_cast(self) -> Option<$Dst> { - if $cond { - Some(az::cast(self)) - } else { - None - } - } - } - }; - - (impl<$Frac:ident: $LeEqU:ident> StaticCast<$Dst:ty> for $Src:ty { $cond:expr }) => { - #[deprecated(since = "0.5.6", note = "deprecated in az crate")] - #[allow(deprecated)] - ///
Deprecated since 0.5.6: - ///

deprecated in az crate since 0.3.1; use case is unclear

- impl<$Frac: $LeEqU> StaticCast<$Dst> for $Src { - #[inline] - fn static_cast(self) -> Option<$Dst> { - if $cond { - Some(az::cast(self)) - } else { - None - } - } - } - }; - - ($SrcI:ident, $SrcU:ident($LeEqUSrc:ident); $DstI:ident, $DstU:ident($LeEqUDst:ident)) => { - compile_time! { - impl StaticCast<$DstI> - for $SrcI - { - <$DstI>::INT_NBITS >= <$SrcI>::INT_NBITS - } - } - - compile_time! { - impl StaticCast<$DstU> - for $SrcI - { - false - } - } - - compile_time! { - impl StaticCast<$DstI> - for $SrcU - { - <$DstI>::INT_NBITS > <$SrcU>::INT_NBITS - } - } - - compile_time! { - impl StaticCast<$DstU> - for $SrcU - { - <$DstU>::INT_NBITS >= <$SrcU>::INT_NBITS - } - } - }; - - ($FixedI:ident, $FixedU:ident($LeEqU:ident); int $DstI:ident, $DstU:ident) => { - compile_time! { - impl StaticCast<$DstI> for $FixedI { - 8 * mem::size_of::<$DstI>() as u32 >= <$FixedI>::INT_NBITS - } - } - - compile_time! { - impl StaticCast<$DstI> for $FixedU { - 8 * mem::size_of::<$DstI>() as u32 > <$FixedU>::INT_NBITS - } - } - - compile_time! { - impl StaticCast<$DstU> for $FixedI { - false - } - } - - compile_time! { - impl StaticCast<$DstU> for $FixedU { - 8 * mem::size_of::<$DstU>() as u32 >= <$FixedU>::INT_NBITS - } - } - }; - - (int $SrcI:ident, $SrcU:ident; $FixedI:ident, $FixedU:ident($LeEqU:ident)) => { - compile_time! { - impl StaticCast<$FixedI> for $SrcI { - <$FixedI>::INT_NBITS >= 8 * mem::size_of::<$SrcI>() as u32 - } - } - - compile_time! { - impl StaticCast<$FixedU> for $SrcI { - false - } - } - - compile_time! { - impl StaticCast<$FixedI> for $SrcU { - <$FixedI>::INT_NBITS > 8 * mem::size_of::<$SrcU>() as u32 - } - } - - compile_time! { - impl StaticCast<$FixedU> for $SrcU { - <$FixedU>::INT_NBITS >= 8 * mem::size_of::<$SrcU>() as u32 - } - } - }; - - ($Fixed:ident($LeEqU:ident); float $Dst:ident) => { - compile_time! { - impl StaticCast<$Dst> for $Fixed { - true - } - } - }; - - (float $Src:ident; $Fixed:ident($LeEqU:ident)) => { - compile_time! { - impl StaticCast<$Fixed> for $Src { - false - } - } - }; -} - -macro_rules! run_time_num { +macro_rules! cast_num { ($Src:ident($LeEqUSrc:ident); $($Dst:ident($LeEqUDst:ident),)*) => { $( - run_time! { $Src($LeEqUSrc); $Dst($LeEqUDst) } + cast! { $Src($LeEqUSrc); $Dst($LeEqUDst) } )* }; ($Fixed:ident($LeEqU:ident); $($Num:ident,)*) => { $( - run_time! { $Fixed($LeEqU); $Num } - run_time! { $Num; $Fixed($LeEqU) } + cast! { $Fixed($LeEqU); $Num } + cast! { $Num; $Fixed($LeEqU) } )* }; ($($Fixed:ident($LeEqU:ident),)*) => { $( - run_time_num! { + cast_num! { $Fixed($LeEqU); FixedI8(LeEqU8), FixedI16(LeEqU16), FixedI32(LeEqU32), FixedI64(LeEqU64), FixedI128(LeEqU128), FixedU8(LeEqU8), FixedU16(LeEqU16), FixedU32(LeEqU32), FixedU64(LeEqU64), FixedU128(LeEqU128), } - run_time! { bool; $Fixed($LeEqU) } - run_time_num! { + cast! { bool; $Fixed($LeEqU) } + cast_num! { $Fixed($LeEqU); i8, i16, i32, i64, i128, isize, u8, u16, u32, u64, u128, usize, f32, f64, } #[cfg(feature = "f16")] - run_time_num! { + cast_num! { $Fixed($LeEqU); f16, bf16, } )* }; } -run_time_num! { - FixedI8(LeEqU8), FixedI16(LeEqU16), FixedI32(LeEqU32), FixedI64(LeEqU64), FixedI128(LeEqU128), - FixedU8(LeEqU8), FixedU16(LeEqU16), FixedU32(LeEqU32), FixedU64(LeEqU64), FixedU128(LeEqU128), -} - -macro_rules! compile_time_fixed { - ( - $SrcI:ident, $SrcU:ident($LeEqUSrc:ident); $(($DstI:ident, $DstU:ident($LeEqUDst:ident)),)* - ) => { $( - compile_time! { $SrcI, $SrcU($LeEqUSrc); $DstI, $DstU($LeEqUDst) } - )* }; - ($($FixedI:ident, $FixedU:ident($LeEqU:ident),)*) => { $( - compile_time_fixed! { - $FixedI, $FixedU($LeEqU); - (FixedI8, FixedU8(LeEqU8)), - (FixedI16, FixedU16(LeEqU16)), - (FixedI32, FixedU32(LeEqU32)), - (FixedI64, FixedU64(LeEqU64)), - (FixedI128, FixedU128(LeEqU128)), - } - )* }; -} - -compile_time_fixed! { - FixedI8, FixedU8(LeEqU8), - FixedI16, FixedU16(LeEqU16), - FixedI32, FixedU32(LeEqU32), - FixedI64, FixedU64(LeEqU64), - FixedI128, FixedU128(LeEqU128), -} - -macro_rules! compile_time_int { - ($FixedI:ident, $FixedU:ident($LeEqU:ident); $(($IntI:ident, $IntU:ident),)*) => { $( - compile_time! { $FixedI, $FixedU($LeEqU); int $IntI, $IntU } - compile_time! { int $IntI, $IntU; $FixedI, $FixedU($LeEqU) } - )* }; - ($($FixedI:ident, $FixedU:ident($LeEqU:ident),)*) => { $( - compile_time! { - impl StaticCast<$FixedI> for bool { - <$FixedI>::INT_NBITS > 1 - } - } - - compile_time! { - impl StaticCast<$FixedU> for bool { - <$FixedU>::INT_NBITS >= 1 - } - } - - compile_time_int! { - $FixedI, $FixedU($LeEqU); - (i8, u8), - (i16, u16), - (i32, u32), - (i64, u64), - (i128, u128), - (isize, usize), - } - )* }; -} - -compile_time_int! { - FixedI8, FixedU8(LeEqU8), - FixedI16, FixedU16(LeEqU16), - FixedI32, FixedU32(LeEqU32), - FixedI64, FixedU64(LeEqU64), - FixedI128, FixedU128(LeEqU128), -} - -macro_rules! compile_time_float { - ($Fixed:ident($LeEqU:ident); $($Float:ident,)*) => { $( - compile_time! { $Fixed($LeEqU); float $Float } - compile_time! { float $Float; $Fixed($LeEqU) } - )* }; - ($($Fixed:ident($LeEqU:ident),)*) => { $( - compile_time_float! { - $Fixed($LeEqU); - f32, f64, - } - #[cfg(feature = "f16")] - compile_time_float! { - $Fixed($LeEqU); - f16, bf16, - } - )* }; -} - -compile_time_float! { +cast_num! { FixedI8(LeEqU8), FixedI16(LeEqU16), FixedI32(LeEqU32), FixedI64(LeEqU64), FixedI128(LeEqU128), FixedU8(LeEqU8), FixedU16(LeEqU16), FixedU32(LeEqU32), FixedU64(LeEqU64), FixedU128(LeEqU128), } diff --git a/src/macros_frac.rs b/src/macros_frac.rs index f1566ac..e452c7c 100644 --- a/src/macros_frac.rs +++ b/src/macros_frac.rs @@ -1075,42 +1075,6 @@ assert_eq!(Fix::from_num(-7.5).overflowing_rem_euclid_int(20), (Fix::from_num(-3 } } } - - /// Returns the number of integer bits. - #[inline] - #[deprecated(since = "0.5.5", note = "use `INT_NBITS` instead")] - pub fn int_nbits() -> u32 { - Self::INT_NBITS - } - - /// Returns the number of fractional bits. - #[inline] - #[deprecated(since = "0.5.5", note = "use `FRAC_NBITS` instead")] - pub fn frac_nbits() -> u32 { - Self::FRAC_NBITS - } - - /// Remainder for division by an integer. - /// - /// # Panics - /// - /// Panics if the divisor is zero. - #[inline] - #[deprecated(since = "0.5.3", note = "cannot overflow, use `%` or `Rem::rem` instead")] - pub fn wrapping_rem_int(self, rhs: $Inner) -> $Fixed { - self % rhs - } - - /// Remainder for division by an integer. - /// - /// # Panics - /// - /// Panics if the divisor is zero. - #[inline] - #[deprecated(since = "0.5.3", note = "cannot overflow, use `%` or `Rem::rem` instead")] - pub fn overflowing_rem_int(self, rhs: $Inner) -> ($Fixed, bool) { - (self % rhs, false) - } } }; } diff --git a/src/macros_no_frac.rs b/src/macros_no_frac.rs index b3e574d..d29ad15 100644 --- a/src/macros_no_frac.rs +++ b/src/macros_no_frac.rs @@ -1423,20 +1423,6 @@ assert_eq!(Fix::MIN.overflowing_abs(), (Fix::MIN, true)); let not_mask = (cond as $Inner).wrapping_sub(1); Self::from_bits((self.to_bits() & !not_mask) | (otherwise.to_bits() & not_mask)) } - - /// Returns the smallest value that can be represented. - #[inline] - #[deprecated(since = "0.5.5", note = "replaced by `MIN`")] - pub const fn min_value() -> $Fixed { - Self::MIN - } - - /// Returns the largest value that can be represented. - #[inline] - #[deprecated(since = "0.5.5", note = "replaced by `MAX`")] - pub const fn max_value() -> $Fixed { - Self::MAX - } } }; } diff --git a/src/traits.rs b/src/traits.rs index 4287f65..91b3edf 100644 --- a/src/traits.rs +++ b/src/traits.rs @@ -997,62 +997,6 @@ where /// [`bool`]: https://doc.rust-lang.org/nightly/std/primitive.bool.html /// [tuple]: https://doc.rust-lang.org/nightly/std/primitive.tuple.html fn overflowing_shr(self, rhs: u32) -> (Self, bool); - - /// Returns the smallest value that can be represented. - #[inline] - #[deprecated(since = "0.5.5", note = "replaced by `MIN`")] - fn min_value() -> Self { - Self::MIN - } - - /// Returns the largest value that can be represented. - #[inline] - #[deprecated(since = "0.5.5", note = "replaced by `MAX`")] - fn max_value() -> Self { - Self::MAX - } - - /// Returns the number of integer bits. - #[inline] - #[deprecated(since = "0.5.5", note = "replaced by `INT_NBITS`")] - fn int_nbits() -> u32 { - Self::INT_NBITS - } - - /// Returns the number of fractional bits. - #[inline] - #[deprecated(since = "0.5.5", note = "replaced by `FRAC_NBITS`")] - fn frac_nbits() -> u32 { - Self::FRAC_NBITS - } - - /// Remainder for division by an integer. - /// - /// # Panics - /// - /// Panics if the divisor is zero. - #[inline] - #[deprecated( - since = "0.5.3", - note = "cannot overflow, use `%` or `Rem::rem` instead" - )] - fn wrapping_rem_int(self, rhs: Self::Bits) -> Self { - self % rhs - } - - /// Remainder for division by an integer. - /// - /// # Panics - /// - /// Panics if the divisor is zero. - #[inline] - #[deprecated( - since = "0.5.3", - note = "cannot overflow, use `%` or `Rem::rem` instead" - )] - fn overflowing_rem_int(self, rhs: Self::Bits) -> (Self, bool) { - (self % rhs, false) - } } /// This trait provides methods common to all signed fixed-point numbers. diff --git a/src/wrapping.rs b/src/wrapping.rs index bc78d26..b527798 100644 --- a/src/wrapping.rs +++ b/src/wrapping.rs @@ -619,34 +619,6 @@ impl Wrapping { pub fn rem_euclid_int(self, divisor: F::Bits) -> Wrapping { Wrapping(self.0.wrapping_rem_euclid_int(divisor)) } - - /// Returns the smallest value that can be represented. - #[inline] - #[deprecated(since = "0.5.5", note = "replaced by `MIN`")] - pub fn min_value() -> Wrapping { - Self::MIN - } - - /// Returns the largest value that can be represented. - #[inline] - #[deprecated(since = "0.5.5", note = "replaced by `MAX`")] - pub fn max_value() -> Wrapping { - Self::MAX - } - - /// Returns the number of integer bits. - #[inline] - #[deprecated(since = "0.5.5", note = "replaced by `INT_NBITS`")] - pub fn int_nbits() -> u32 { - Self::INT_NBITS - } - - /// Returns the number of fractional bits. - #[inline] - #[deprecated(since = "0.5.5", note = "replaced by `FRAC_NBITS`")] - pub fn frac_nbits() -> u32 { - Self::FRAC_NBITS - } } impl Wrapping {