Skip to content

Commit

Permalink
Fix lint checks with newer rustc versions.
Browse files Browse the repository at this point in the history
Fix rustfmt and clippy checks up to nightly-2022-05-12.
  • Loading branch information
Alexhuszagh committed May 14, 2022
1 parent 24b42ba commit 5c2732c
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 24 deletions.
2 changes: 1 addition & 1 deletion lexical-benchmark/input.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Input data reader and random-number generator for benchmarks.
//! This is adapted from fast-float-rust.
#![allow(dead_code, unused_macros)]
#![allow(dead_code, unused_macros, unused_macro_rules)]

use core::fmt::Debug;
use core::str::FromStr;
Expand Down
8 changes: 0 additions & 8 deletions lexical-parse-float/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,6 @@ macro_rules! index_unchecked_mut {
($x:ident[$i:expr]) => {
*$x.get_unchecked_mut($i)
};

($x:ident[$i:expr] = $y:ident[$j:expr]) => {
*$x.get_unchecked_mut($i) = *$y.get_unchecked($j)
};
}

/// Index a buffer, with bounds checking.
Expand All @@ -40,8 +36,4 @@ macro_rules! index_unchecked_mut {
($x:ident[$i:expr]) => {
$x[$i]
};

($x:ident[$i:expr] = $y:ident[$j:expr]) => {
$x[$i] = $y[$j]
};
}
4 changes: 4 additions & 0 deletions lexical-parse-float/src/number.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,8 @@ impl<'a> Number<'a> {
///
/// There is an exception: disguised fast-path cases, where we can shift
/// powers-of-10 from the exponent to the significant digits.
// `set_precision` doesn't return a unit value on x87 FPUs.
#[allow(clippy::let_unit_value)]
pub fn try_fast_path<F: RawFloat, const FORMAT: u128>(&self) -> Option<F> {
let format = NumberFormat::<FORMAT> {};
debug_assert!(format.mantissa_radix() == format.exponent_base());
Expand Down Expand Up @@ -99,6 +101,8 @@ impl<'a> Number<'a> {
}

/// Force a fast-path algorithm, even when it may not be accurate.
// `set_precision` doesn't return a unit value on x87 FPUs.
#[allow(clippy::let_unit_value)]
pub fn force_fast_path<F: RawFloat, const FORMAT: u128>(&self) -> F {
let format = NumberFormat::<FORMAT> {};
debug_assert!(format.mantissa_radix() == format.exponent_base());
Expand Down
17 changes: 2 additions & 15 deletions lexical-parse-float/src/slow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,6 @@ macro_rules! add_temporary {
$result.data.add_small($value).unwrap();
};

// # Safety
//
// Safe is `counter <= step`, or smaller than the table size.
($format:ident, $result:ident, $counter:ident, $value:ident) => {
if $counter != 0 {
// SAFETY: safe, since `counter <= step`, or smaller than the table size.
let small_power = unsafe { f64::int_pow_fast_path($counter, $format.radix()) };
add_temporary!(@mul $result, small_power as Limb, $value);
$counter = 0;
$value = 0;
}
};

// Add a temporary where we won't read the counter results internally.
//
// # Safety
Expand Down Expand Up @@ -572,7 +559,7 @@ pub fn byte_comp<F: RawFloat, const FORMAT: u128>(

// Now, create a scaling factor for the digit count.
let mut factor = Bigfloat::from_u32(1);
factor.pow(format.radix(), sci_exp.abs() as u32).unwrap();
factor.pow(format.radix(), sci_exp.unsigned_abs()).unwrap();
let mut num: Bigfloat;
let mut den: Bigfloat;

Expand Down Expand Up @@ -601,7 +588,7 @@ pub fn byte_comp<F: RawFloat, const FORMAT: u128>(
// Need to scale the numerator or denominator to the same value.
// We don't want to shift the denominator, so...
let diff = den.exp - num.exp;
let shift = diff.abs() as usize;
let shift = diff.unsigned_abs() as usize;
if diff < 0 {
// Need to shift the numerator left.
num.shl(shift).unwrap();
Expand Down
8 changes: 8 additions & 0 deletions lexical-write-integer/src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
//! and other tests and careful validation against a wide range
//! of randomized input. Parsers are much trickier to validate.
// `index_unchecked_mut`'s 2nd arm is unused in `compact`.
#![cfg_attr(feature = "compact", allow(unused_macros))]
#![cfg_attr(feature = "compact", allow(unused_macro_rules))]
#![doc(hidden)]

/// Index a buffer, without bounds checking.
Expand All @@ -16,6 +18,9 @@ macro_rules! index_unchecked {
}

/// Index a buffer and get a mutable reference, without bounds checking.
// The `($x:ident[$i:expr] = $y:ident[$j:expr])` is not used with `compact`.
// The newer version of the lint is `unused_macro_rules`, but this isn't
// supported until nightly-2022-05-12.
#[cfg(not(feature = "safe"))]
macro_rules! index_unchecked_mut {
($x:ident[$i:expr]) => {
Expand Down Expand Up @@ -44,6 +49,9 @@ macro_rules! index_unchecked {
}

/// Index a buffer and get a mutable reference, with bounds checking.
// The `($x:ident[$i:expr] = $y:ident[$j:expr])` is not used with `compact`.
// The newer version of the lint is `unused_macro_rules`, but this isn't
// supported until nightly-2022-05-12.
#[cfg(feature = "safe")]
macro_rules! index_unchecked_mut {
($x:ident[$i:expr]) => {
Expand Down

0 comments on commit 5c2732c

Please sign in to comment.