diff --git a/Cargo.toml b/Cargo.toml index 8cdfc04167d..a5e6ee8da85 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -687,7 +687,6 @@ should_panic_without_expect = "allow" # 2 doc_markdown = "allow" unused_self = "allow" enum_glob_use = "allow" -unreadable_literal = "allow" unnested_or_patterns = "allow" implicit_hasher = "allow" struct_field_names = "allow" diff --git a/src/uucore/src/lib/features/format/num_format.rs b/src/uucore/src/lib/features/format/num_format.rs index da263ad96eb..9a09b3f7dec 100644 --- a/src/uucore/src/lib/features/format/num_format.rs +++ b/src/uucore/src/lib/features/format/num_format.rs @@ -1127,11 +1127,11 @@ mod test { ForceDecimal::No, ) }; - assert_eq!(f(0.1171875), "0.117188"); - assert_eq!(f(0.01171875), "0.0117188"); - assert_eq!(f(0.001171875), "0.00117187"); - assert_eq!(f(0.0001171875), "0.000117187"); - assert_eq!(f(0.001171875001), "0.00117188"); + assert_eq!(f(0.117_187_5), "0.117188"); + assert_eq!(f(0.011_718_75), "0.0117188"); + assert_eq!(f(0.001_171_875), "0.00117187"); + assert_eq!(f(0.000_117_187_5), "0.000117187"); + assert_eq!(f(0.001_171_875_001), "0.00117188"); } #[test] @@ -1148,7 +1148,7 @@ mod test { assert_eq!(f(0.001), "0.001"); assert_eq!(f(0.0001), "0.0001"); assert_eq!(f(0.00001), "1e-05"); - assert_eq!(f(0.000001), "1e-06"); + assert_eq!(f(0.000_001), "1e-06"); } /// Wrapper function to get a string out of Format.fmt() diff --git a/src/uucore/src/lib/features/parser/num_parser.rs b/src/uucore/src/lib/features/parser/num_parser.rs index b23f51fb52e..d690ec33f22 100644 --- a/src/uucore/src/lib/features/parser/num_parser.rs +++ b/src/uucore/src/lib/features/parser/num_parser.rs @@ -583,7 +583,7 @@ mod tests { u64::extended_parse("-9223372036854775808") // i64::MIN ); assert_eq!( - Ok(1123372036854675616), + Ok(1_123_372_036_854_675_616), u64::extended_parse("-17323372036854876000") // 2*i64::MIN ); assert_eq!(Ok(1), u64::extended_parse("-18446744073709551615")); // -u64::MAX @@ -679,10 +679,10 @@ mod tests { assert_eq!(Ok(123.15), f64::extended_parse("0123.15")); assert_eq!(Ok(123.15), f64::extended_parse("+0123.15")); assert_eq!(Ok(-123.15), f64::extended_parse("-0123.15")); - assert_eq!(Ok(12315000.0), f64::extended_parse("123.15e5")); - assert_eq!(Ok(-12315000.0), f64::extended_parse("-123.15e5")); - assert_eq!(Ok(12315000.0), f64::extended_parse("123.15E+5")); - assert_eq!(Ok(0.0012315), f64::extended_parse("123.15E-5")); + assert_eq!(Ok(12_315_000.0), f64::extended_parse("123.15e5")); + assert_eq!(Ok(-12_315_000.0), f64::extended_parse("-123.15e5")); + assert_eq!(Ok(12_315_000.0), f64::extended_parse("123.15E+5")); + assert_eq!(Ok(0.001_231_5), f64::extended_parse("123.15E-5")); assert_eq!( Ok(0.15), f64::extended_parse(".150000000000000000000000000231313") @@ -933,7 +933,7 @@ mod tests { // We cannot really check that 'e' is not a valid exponent indicator for hex floats... // but we can check that the number still gets parsed properly: 0x0.8e5 is 0x8e5 / 16**3 - assert_eq!(Ok(0.555908203125), f64::extended_parse("0x0.8e5")); + assert_eq!(Ok(0.555_908_203_125), f64::extended_parse("0x0.8e5")); assert_eq!( f64::extended_parse("0x0.1p"), diff --git a/src/uucore/src/lib/features/parser/parse_time.rs b/src/uucore/src/lib/features/parser/parse_time.rs index 4abf85a1d4e..5435bd8231a 100644 --- a/src/uucore/src/lib/features/parser/parse_time.rs +++ b/src/uucore/src/lib/features/parser/parse_time.rs @@ -87,7 +87,7 @@ pub fn from_str(string: &str, allow_suffixes: bool) -> Result return Ok(Duration::MAX); } // early return if number is too small (< 1 ns) - if !bd.is_zero() && bd < bigdecimal::BigDecimal::from_f64(0.0000000001).unwrap() { + if !bd.is_zero() && bd < bigdecimal::BigDecimal::from_f64(0.000_000_000_1).unwrap() { return Ok(NANOSECOND_DURATION); } bd diff --git a/src/uucore/src/lib/features/sum.rs b/src/uucore/src/lib/features/sum.rs index 0670bd50ea8..5272ab3c139 100644 --- a/src/uucore/src/lib/features/sum.rs +++ b/src/uucore/src/lib/features/sum.rs @@ -175,10 +175,10 @@ impl Crc { crc_fast::CrcParams::new( "CRC-32/CKSUM", // Name 32, // Width - 0x04c11db7, // Polynomial - 0x00000000, // Initial CRC value: 0 (not 0xffffffff) + 0x04c1_1db7, // Polynomial + 0x0000_0000, // Initial CRC value: 0 (not 0xffffffff) false, // No input reflection (refin) - 0xffffffff, // XOR output with 0xffffffff (xorout) + 0xffff_ffff, // XOR output with 0xffffffff (xorout) 0, // Check value (not used) ) } @@ -245,7 +245,7 @@ impl Digest for CRC32B { let result = self.digest.finalize(); // crc_fast returns a 64-bit value, but CRC32B should be 32-bit // Take the lower 32 bits and convert to big-endian bytes - let crc32_value = (result & 0xffffffff) as u32; + let crc32_value = (result & 0xffff_ffff) as u32; out.copy_from_slice(&crc32_value.to_be_bytes()); } @@ -601,7 +601,7 @@ mod tests { assert_ne!(empty_result, test_result); // Test known value: "test" should give 3076352578 - assert_eq!(test_result, 3076352578); + assert_eq!(test_result, 3_076_352_578); } #[test] @@ -653,9 +653,9 @@ mod tests { // Test against our CRC implementation values // Note: These are the correct values for our POSIX cksum implementation let test_cases = [ - ("", 4294967295_u64), - ("a", 1220704766_u64), - ("abc", 1219131554_u64), + ("", 4_294_967_295_u64), + ("a", 1_220_704_766_u64), + ("abc", 1_219_131_554_u64), ]; for (input, expected) in test_cases { diff --git a/tests/by-util/test_dd.rs b/tests/by-util/test_dd.rs index 7aaa90eb2d2..828a1e04311 100644 --- a/tests/by-util/test_dd.rs +++ b/tests/by-util/test_dd.rs @@ -1901,7 +1901,7 @@ fn test_skip_overflow() { #[cfg(target_os = "linux")] fn test_nocache_eof() { let (at, mut ucmd) = at_and_ucmd!(); - at.write_bytes("in.f", &vec![0u8; 1234567]); + at.write_bytes("in.f", &vec![0u8; 1_234_567]); ucmd.args(&[ "if=in.f", "of=out.f", @@ -1910,7 +1910,7 @@ fn test_nocache_eof() { "status=noxfer", ]) .succeeds(); - assert_eq!(at.read_bytes("out.f").len(), 1234567); + assert_eq!(at.read_bytes("out.f").len(), 1_234_567); } #[test] @@ -1918,7 +1918,7 @@ fn test_nocache_eof() { fn test_nocache_eof_fadvise_zero_length() { use std::process::Command; let (at, _ucmd) = at_and_ucmd!(); - at.write_bytes("in.f", &vec![0u8; 1234567]); + at.write_bytes("in.f", &vec![0u8; 1_234_567]); let strace_file = at.plus_as_string("strace.out"); let result = Command::new("strace") diff --git a/tests/by-util/test_shred.rs b/tests/by-util/test_shred.rs index a0aa7b505e8..81f69fb5c66 100644 --- a/tests/by-util/test_shred.rs +++ b/tests/by-util/test_shred.rs @@ -339,7 +339,7 @@ fn test_shred_non_utf8_paths() { fn test_gnu_shred_passes_20() { let (at, mut ucmd) = at_and_ucmd!(); - let us_data = vec![0x55; 102400]; // 100K of 'U' bytes + let us_data = vec![0x55; 102_400]; // 100K of 'U' bytes at.write_bytes("Us", &us_data); let file = "f"; @@ -397,7 +397,7 @@ fn test_gnu_shred_passes_20() { fn test_gnu_shred_passes_different_counts() { let (at, mut ucmd) = at_and_ucmd!(); - let us_data = vec![0x55; 102400]; + let us_data = vec![0x55; 102_400]; at.write_bytes("Us", &us_data); let file = "f";