Skip to content

Commit 5c2732c

Browse files
committed
Fix lint checks with newer rustc versions.
Fix rustfmt and clippy checks up to nightly-2022-05-12.
1 parent 24b42ba commit 5c2732c

File tree

5 files changed

+15
-24
lines changed

5 files changed

+15
-24
lines changed

lexical-benchmark/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! Input data reader and random-number generator for benchmarks.
22
//! This is adapted from fast-float-rust.
33
4-
#![allow(dead_code, unused_macros)]
4+
#![allow(dead_code, unused_macros, unused_macro_rules)]
55

66
use core::fmt::Debug;
77
use core::str::FromStr;

lexical-parse-float/src/index.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,6 @@ macro_rules! index_unchecked_mut {
2020
($x:ident[$i:expr]) => {
2121
*$x.get_unchecked_mut($i)
2222
};
23-
24-
($x:ident[$i:expr] = $y:ident[$j:expr]) => {
25-
*$x.get_unchecked_mut($i) = *$y.get_unchecked($j)
26-
};
2723
}
2824

2925
/// Index a buffer, with bounds checking.
@@ -40,8 +36,4 @@ macro_rules! index_unchecked_mut {
4036
($x:ident[$i:expr]) => {
4137
$x[$i]
4238
};
43-
44-
($x:ident[$i:expr] = $y:ident[$j:expr]) => {
45-
$x[$i] = $y[$j]
46-
};
4739
}

lexical-parse-float/src/number.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ impl<'a> Number<'a> {
5353
///
5454
/// There is an exception: disguised fast-path cases, where we can shift
5555
/// powers-of-10 from the exponent to the significant digits.
56+
// `set_precision` doesn't return a unit value on x87 FPUs.
57+
#[allow(clippy::let_unit_value)]
5658
pub fn try_fast_path<F: RawFloat, const FORMAT: u128>(&self) -> Option<F> {
5759
let format = NumberFormat::<FORMAT> {};
5860
debug_assert!(format.mantissa_radix() == format.exponent_base());
@@ -99,6 +101,8 @@ impl<'a> Number<'a> {
99101
}
100102

101103
/// Force a fast-path algorithm, even when it may not be accurate.
104+
// `set_precision` doesn't return a unit value on x87 FPUs.
105+
#[allow(clippy::let_unit_value)]
102106
pub fn force_fast_path<F: RawFloat, const FORMAT: u128>(&self) -> F {
103107
let format = NumberFormat::<FORMAT> {};
104108
debug_assert!(format.mantissa_radix() == format.exponent_base());

lexical-parse-float/src/slow.rs

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -295,19 +295,6 @@ macro_rules! add_temporary {
295295
$result.data.add_small($value).unwrap();
296296
};
297297

298-
// # Safety
299-
//
300-
// Safe is `counter <= step`, or smaller than the table size.
301-
($format:ident, $result:ident, $counter:ident, $value:ident) => {
302-
if $counter != 0 {
303-
// SAFETY: safe, since `counter <= step`, or smaller than the table size.
304-
let small_power = unsafe { f64::int_pow_fast_path($counter, $format.radix()) };
305-
add_temporary!(@mul $result, small_power as Limb, $value);
306-
$counter = 0;
307-
$value = 0;
308-
}
309-
};
310-
311298
// Add a temporary where we won't read the counter results internally.
312299
//
313300
// # Safety
@@ -572,7 +559,7 @@ pub fn byte_comp<F: RawFloat, const FORMAT: u128>(
572559

573560
// Now, create a scaling factor for the digit count.
574561
let mut factor = Bigfloat::from_u32(1);
575-
factor.pow(format.radix(), sci_exp.abs() as u32).unwrap();
562+
factor.pow(format.radix(), sci_exp.unsigned_abs()).unwrap();
576563
let mut num: Bigfloat;
577564
let mut den: Bigfloat;
578565

@@ -601,7 +588,7 @@ pub fn byte_comp<F: RawFloat, const FORMAT: u128>(
601588
// Need to scale the numerator or denominator to the same value.
602589
// We don't want to shift the denominator, so...
603590
let diff = den.exp - num.exp;
604-
let shift = diff.abs() as usize;
591+
let shift = diff.unsigned_abs() as usize;
605592
if diff < 0 {
606593
// Need to shift the numerator left.
607594
num.shl(shift).unwrap();

lexical-write-integer/src/index.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
//! and other tests and careful validation against a wide range
55
//! of randomized input. Parsers are much trickier to validate.
66
7+
// `index_unchecked_mut`'s 2nd arm is unused in `compact`.
78
#![cfg_attr(feature = "compact", allow(unused_macros))]
9+
#![cfg_attr(feature = "compact", allow(unused_macro_rules))]
810
#![doc(hidden)]
911

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

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

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

0 commit comments

Comments
 (0)