Skip to content

Commit

Permalink
Fix all warnings and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Gelbpunkt committed Feb 3, 2021
1 parent a2be720 commit 05f2cf9
Show file tree
Hide file tree
Showing 12 changed files with 266 additions and 266 deletions.
6 changes: 3 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,17 +22,17 @@ exclude = [
travis-ci = { repository = "Alexhuszagh/rust-lexical" }

[dependencies]
cfg-if = "0.1"
cfg-if = "1.0"
lexical-core = { path = "lexical-core", version = "^0.7.4", default-features = false }
# The following are only required for comprehensive float unittests.
# IE, internal testing only:
rand = { version = "0.4", optional = true }
rand = { version = "0.8", optional = true }
serde = { version = "1.0", optional = true }
serde_derive = { version = "1.0", optional = true }
toml = { version = "0.5", optional = true }

[dev-dependencies]
approx = "0.3.0"
approx = "0.4.0"
criterion = "0.3"
dtoa = "0.4"
ryu_impl = { version = "1.0", package = "ryu" }
Expand Down
8 changes: 4 additions & 4 deletions lexical-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ travis-ci = { repository = "Alexhuszagh/rust-lexical" }

[dependencies]
bitflags = "1.2"
cfg-if = "0.1"
cfg-if = "1.0"
# Use static_assertions for correct or format features.
static_assertions = { version = "1", optional = true }
# Use arrayvec for the correct parser.
Expand All @@ -34,9 +34,9 @@ dtoa = { version = "0.4", optional = true }
ryu = { version = "1.0", optional = true }

[dev-dependencies]
approx = "0.3.0"
quickcheck = "0.9.0"
proptest = "0.9.4"
approx = "0.4.0"
quickcheck = "1.0.3"
proptest = "0.10.1"

[features]
default = ["correct", "ryu", "std"]
Expand Down
14 changes: 7 additions & 7 deletions lexical-core/src/atof/algorithm/bhcomp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub(super) fn parse_mantissa<'a, Data>(data: Data, radix: u32, max_digits: usize
let small_powers = Bigint::small_powers(radix);
let count = data.mantissa_digits();
let bits = count / integral_binary_factor(radix).as_usize();
let bytes = bits / Limb::BITS;
let bytes = bits / <Limb as Integer>::BITS;

// Main loop
let step = small_powers.len() - 2;
Expand Down Expand Up @@ -102,8 +102,8 @@ pub(super) fn parse_mantissa<'a, Data>(data: Data, radix: u32, max_digits: usize
result
}

/// Implied method to calculate the number of digits from a 32-bit float.
perftools_inline!{
/// Implied method to calculate the number of digits from a 32-bit float.
fn max_digits_f32(radix: u32) -> Option<usize> {
match radix {
6 => Some(103),
Expand All @@ -124,8 +124,8 @@ fn max_digits_f32(radix: u32) -> Option<usize> {
}
}}

/// Implied method to calculate the number of digits from a 64-bit float.
perftools_inline!{
/// Implied method to calculate the number of digits from a 64-bit float.
fn max_digits_f64(radix: u32) -> Option<usize> {
match radix {
6 => Some(682),
Expand All @@ -146,6 +146,7 @@ fn max_digits_f64(radix: u32) -> Option<usize> {
}
}}

perftools_inline!{
/// Calculate the maximum number of digits possible in the mantissa.
///
/// Returns the maximum number of digits plus one.
Expand All @@ -172,7 +173,6 @@ fn max_digits_f64(radix: u32) -> Option<usize> {
/// `-emin + p2 + math.floor((emin+1)*math.log(2, b) - math.log(1-2**(-p2), b))`
///
/// This was used to calculate the maximum number of digits for [2, 36].
perftools_inline!{
pub(super) fn max_digits<F>(radix: u32)
-> Option<usize>
where F: Float
Expand Down Expand Up @@ -216,10 +216,10 @@ macro_rules! toward_cb {
};
}

perftools_inline!{
/// Custom rounding for truncated mantissa.
///
/// Respect rounding rules in the config file.
perftools_inline!{
#[allow(unused_variables)]
pub(super) fn round_to_native<F>(fp: &mut ExtendedFloat80, is_truncated: bool, kind: RoundingKind)
where F: FloatType
Expand Down Expand Up @@ -254,8 +254,8 @@ pub(super) fn round_to_native<F>(fp: &mut ExtendedFloat80, is_truncated: bool, k
/// Maximum number of digits before reverting to bigcomp.
const LARGE_POWER_MAX: usize = 1 << 15;

/// Check if we need to use bigcomp.
perftools_inline!{
/// Check if we need to use bigcomp.
pub(super) fn use_bigcomp(radix: u32, count: usize)
-> bool
{
Expand Down Expand Up @@ -283,7 +283,7 @@ pub(super) fn large_atof<'a, F, Data>(data: Data, radix: u32, max_digits: usize,

// Get the exact representation of the float from the big integer.
let (mant, is_truncated) = bigmant.hi64();
let exp = bigmant.bit_length().as_i32() - u64::BITS.as_i32();
let exp = bigmant.bit_length().as_i32() - <u64 as Integer>::BITS.as_i32();
let mut fp = ExtendedFloat { mant: mant, exp: exp };
round_to_native::<F>(&mut fp, is_truncated, kind);
into_float(fp)
Expand Down
16 changes: 8 additions & 8 deletions lexical-core/src/atof/algorithm/bigcomp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,14 @@ pub(super) fn round_to_native<F>(f: F, order: cmp::Ordering, kind: RoundingKind)

// SHARED

/// Calculate `b` from a a representation of `b` as a float.
perftools_inline!{
/// Calculate `b` from a a representation of `b` as a float.
pub(super) fn b<F: FloatType>(f: F) -> F::ExtendedFloat {
f.into()
}}

/// Calculate `b+h` from a a representation of `b` as a float.
perftools_inline!{
/// Calculate `b+h` from a a representation of `b` as a float.
pub(super) fn bh<F: FloatType>(f: F) -> F::ExtendedFloat {
// None of these can overflow.
let mut b = b(f);
Expand All @@ -89,8 +89,8 @@ pub(super) fn bh<F: FloatType>(f: F) -> F::ExtendedFloat {
b
}}

/// Generate the theoretical float type for the rounding kind.
perftools_inline!{
/// Generate the theoretical float type for the rounding kind.
#[allow(unused_variables)]
pub(super) fn theoretical_float<F>(f: F, kind: RoundingKind)
-> F::ExtendedFloat
Expand All @@ -112,11 +112,11 @@ pub(super) fn theoretical_float<F>(f: F, kind: RoundingKind)

// BIGCOMP

perftools_inline!{
/// Get the appropriate scaling factor from the digit count.
///
/// * `radix` - Radix for the number parsing.
/// * `sci_exponent` - Exponent of basen string in scientific notation.
perftools_inline!{
pub fn scaling_factor(radix: u32, sci_exponent: u32)
-> Bigfloat
{
Expand Down Expand Up @@ -154,7 +154,7 @@ pub(super) fn make_ratio<F: Float>(radix: u32, sci_exponent: i32, f: F, kind: Ro
// Scale the denominator so it has the number of bits
// in the radix as the number of leading zeros.
let wlz = integral_binary_factor(radix).as_usize();
let nlz = den.leading_zeros().wrapping_sub(wlz) & (u32::BITS - 1);
let nlz = den.leading_zeros().wrapping_sub(wlz) & (<u32 as Integer>::BITS - 1);
small::ishl_bits(den.data_mut(), nlz);
den.exp -= nlz.as_i32();

Expand All @@ -167,20 +167,20 @@ pub(super) fn make_ratio<F: Float>(radix: u32, sci_exponent: i32, f: F, kind: Ro
small::ishl(num.data_mut(), shift);
num.exp -= shift.as_i32()
} else if diff > 0 {
// Need to shift denominator left, go by a power of Limb::BITS.
// Need to shift denominator left, go by a power of <Limb as Integer>::BITS.
// After this, the numerator will be non-normalized, and the
// denominator will be normalized.
// We need to add one to the quotient,since we're calculating the
// ceiling of the divmod.
let (q, r) = shift.ceil_divmod(Limb::BITS);
let (q, r) = shift.ceil_divmod(<Limb as Integer>::BITS);
// Since we're using a power from the denominator to the
// numerator, we to invert r, not add u32::BITS.
let r = -r;
small::ishl_bits(num.data_mut(), r.as_usize());
num.exp -= r;
if !q.is_zero() {
den.pad_zero_digits(q);
den.exp -= Limb::BITS.as_i32() * q.as_i32();
den.exp -= <Limb as Integer>::BITS.as_i32() * q.as_i32();
}
}

Expand Down
2 changes: 1 addition & 1 deletion lexical-core/src/atof/algorithm/bignum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ if #[cfg(feature = "radix")] {
type IntStorageType = arrayvec::ArrayVec<[Limb; 64]>;
}} // cfg_if

/// Calculate the integral ceiling of the binary factor from a basen number.
perftools_inline!{
/// Calculate the integral ceiling of the binary factor from a basen number.
pub(super) fn integral_binary_factor(radix: u32)
-> u32
{
Expand Down
4 changes: 2 additions & 2 deletions lexical-core/src/atof/algorithm/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ pub trait FloatErrors: Mantissa {
fn error_is_accurate<F: Float>(count: u32, fp: &ExtendedFloat<Self>, kind: RoundingKind) -> bool;
}

/// Check if the error is accurate with a round-nearest rounding scheme.
perftools_inline!{
/// Check if the error is accurate with a round-nearest rounding scheme.
fn nearest_error_is_accurate(errors: u64, fp: &ExtendedFloat<u64>, extrabits: u64)
-> bool
{
Expand Down Expand Up @@ -47,8 +47,8 @@ fn nearest_error_is_accurate(errors: u64, fp: &ExtendedFloat<u64>, extrabits: u6
}
}}

/// Check if the error is accurate with a round-toward rounding scheme.
perftools_inline!{
/// Check if the error is accurate with a round-toward rounding scheme.
#[cfg(feature = "rounding")]
fn toward_error_is_accurate(errors: u64, fp: &ExtendedFloat<u64>, extrabits: u64)
-> bool
Expand Down
16 changes: 8 additions & 8 deletions lexical-core/src/atof/algorithm/format/traits.rs
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ pub(crate) trait FastDataInterface<'a>: FastDataInterfaceImpl<'a> {
/// Get the number format.
fn format(&self) -> NumberFormat;

/// Get the mantissa exponent from the raw exponent.
perftools_inline!{
/// Get the mantissa exponent from the raw exponent.
#[cfg(feature = "correct")]
fn mantissa_exponent(&self, truncated_digits: usize) -> i32 {
mantissa_exponent(self.raw_exponent(), self.fraction_iter().count(), truncated_digits)
Expand Down Expand Up @@ -248,8 +248,8 @@ pub(crate) trait FastDataInterface<'a>: FastDataInterfaceImpl<'a> {
self.set_fraction(self.fraction().map(|x| self.rtrim_zero(x).0));
}}

/// Extract float subcomponents from input bytes.
perftools_inline!{
/// Extract float subcomponents from input bytes.
fn extract(&mut self, bytes: &'a [u8], radix: u32) -> ParseResult<*const u8> {
// Parse the integer, aka, the digits preceding any control characters.
let mut digits = bytes;
Expand Down Expand Up @@ -497,33 +497,33 @@ pub(crate) trait SlowDataInterface<'a>: SlowDataInterfaceImpl<'a> {
/// Iterate over all integer digits.
fn integer_iter(&self) -> Self::IntegerIter;

/// Get number of all integer digits.
perftools_inline!{
/// Get number of all integer digits.
fn integer_digits(&self) -> usize {
self.integer_iter().count()
}}

/// Iterate over all fraction digits
fn fraction_iter(&self) -> Self::FractionIter;

/// Get number of all fraction digits.
perftools_inline!{
/// Get number of all fraction digits.
fn fraction_digits(&self) -> usize {
self.fraction_iter().count()
}}

/// Iterate over significant fraction digits.
fn significant_fraction_iter(&self) -> Self::FractionIter;

/// Get number of significant fraction digits.
perftools_inline!{
/// Get number of significant fraction digits.
fn significant_fraction_digits(&self) -> usize {
self.significant_fraction_iter().count()
}}

perftools_inline!{
/// Get the number of digits in the mantissa.
/// Cannot overflow, since this is based off a single usize input string.
perftools_inline!{
fn mantissa_digits(&self) -> usize {
self.integer_digits() + self.significant_fraction_digits()
}}
Expand All @@ -537,14 +537,14 @@ pub(crate) trait SlowDataInterface<'a>: SlowDataInterfaceImpl<'a> {
/// Get number of truncated digits.
fn truncated_digits(&self) -> usize;

/// Get the mantissa exponent from the raw exponent.
perftools_inline!{
/// Get the mantissa exponent from the raw exponent.
fn mantissa_exponent(&self) -> i32 {
mantissa_exponent(self.raw_exponent(), self.fraction_digits(), self.truncated_digits())
}}

/// Get the scientific exponent from the raw exponent.
perftools_inline!{
/// Get the scientific exponent from the raw exponent.
fn scientific_exponent(&self) -> i32 {
scientific_exponent(self.raw_exponent(), self.integer_digits(), self.digits_start())
}}
Expand Down
Loading

0 comments on commit 05f2cf9

Please sign in to comment.