Skip to content

Commit ea1bfcd

Browse files
authored
Merge branch 'main' into sort/sort-debug-warn.sh
2 parents 87b2101 + 1e11921 commit ea1bfcd

File tree

6 files changed

+11
-87
lines changed

6 files changed

+11
-87
lines changed

.github/workflows/GnuTests.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: GnuTests
22

33
# spell-checker:ignore (abbrev/names) CodeCov gnulib GnuTests Swatinem
44
# spell-checker:ignore (jargon) submodules devel
5-
# spell-checker:ignore (libs/utils) autopoint chksum dpkg getenforce getlimits gperf lcov libexpect limactl pyinotify setenforce shopt valgrind libattr libcap taiki-e zstd cpio
5+
# spell-checker:ignore (libs/utils) chksum dpkg getenforce getlimits gperf lcov libexpect limactl pyinotify setenforce shopt valgrind libattr libcap taiki-e zstd cpio
66
# spell-checker:ignore (options) Ccodegen Coverflow Cpanic Zpanic
77
# spell-checker:ignore (people) Dawid Dziurla * dawidd dtolnay
88
# spell-checker:ignore (vars) FILESET SUBDIRS XPASS
@@ -68,7 +68,7 @@ jobs:
6868
## Install dependencies
6969
sudo apt-get update
7070
## Check that build-gnu.sh works on the non SELinux system by installing libselinux only on lima
71-
sudo apt-get install -y autopoint gperf gdb python3-pyinotify valgrind libexpect-perl libacl1-dev libattr1-dev libcap-dev attr quilt
71+
sudo apt-get install -y gperf gdb python3-pyinotify valgrind libexpect-perl libacl1-dev libattr1-dev libcap-dev attr quilt
7272
curl http://launchpadlibrarian.net/831710181/automake_1.18.1-3_all.deb > automake-1.18.deb
7373
sudo dpkg -i --force-depends automake-1.18.deb
7474
- name: Add various locales
@@ -245,7 +245,7 @@ jobs:
245245
- name: Install dependencies in VM
246246
run: |
247247
lima sudo dnf -y update
248-
lima sudo dnf -y install git autoconf autopoint bison gperf gcc gdb jq libacl-devel libattr-devel libcap-devel libselinux-devel attr rustup clang-devel automake patch quilt
248+
lima sudo dnf -y install git autoconf bison gperf gcc gdb jq libacl-devel libattr-devel libcap-devel libselinux-devel attr rustup clang-devel automake patch quilt
249249
lima rustup-init -y --default-toolchain stable
250250
- name: Copy the sources to VM
251251
run: |

src/uu/cp/src/cp.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,9 +1279,7 @@ fn parse_path_args(
12791279
};
12801280

12811281
if options.strip_trailing_slashes {
1282-
// clippy::assigning_clones added with Rust 1.78
1283-
// Rust version = 1.76 on OpenBSD stable/7.5
1284-
#[cfg_attr(not(target_os = "openbsd"), allow(clippy::assigning_clones))]
1282+
#[allow(clippy::assigning_clones)]
12851283
for source in &mut paths {
12861284
*source = source.components().as_path().to_owned();
12871285
}

src/uu/df/src/filesystem.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -291,9 +291,7 @@ mod tests {
291291
}
292292

293293
#[test]
294-
// clippy::assigning_clones added with Rust 1.78
295-
// Rust version = 1.76 on OpenBSD stable/7.5
296-
#[cfg_attr(not(target_os = "openbsd"), allow(clippy::assigning_clones))]
294+
#[allow(clippy::assigning_clones)]
297295
fn test_dev_name_match() {
298296
let tmp = tempfile::TempDir::new().expect("Failed to create temp dir");
299297
let dev_name = std::fs::canonicalize(tmp.path())

src/uu/tail/src/follow/watch.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,7 @@ impl WatcherRx {
4747
Tested for notify::InotifyWatcher and for notify::PollWatcher.
4848
*/
4949
if let Some(parent) = path.parent() {
50-
// clippy::assigning_clones added with Rust 1.78
51-
// Rust version = 1.76 on OpenBSD stable/7.5
52-
#[cfg_attr(not(target_os = "openbsd"), allow(clippy::assigning_clones))]
50+
#[allow(clippy::assigning_clones)]
5351
if parent.is_dir() {
5452
path = parent.to_owned();
5553
} else {

src/uucore/src/lib/features/parser/num_parser.rs

Lines changed: 3 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,8 @@
77
88
// spell-checker:ignore powf copysign prec ilog inity infinit infs bigdecimal extendedbigdecimal biguint underflowed muls
99

10-
use std::num::NonZeroU64;
11-
1210
use bigdecimal::{
13-
BigDecimal, Context,
11+
BigDecimal,
1412
num_bigint::{BigInt, BigUint, Sign},
1513
};
1614
use num_traits::Signed;
@@ -398,71 +396,6 @@ fn make_error(overflow: bool, negative: bool) -> ExtendedParserError<ExtendedBig
398396
}
399397
}
400398

401-
/// Compute bd**exp using exponentiation by squaring algorithm, while maintaining the
402-
/// precision specified in ctx (the number of digits would otherwise explode).
403-
///
404-
/// Algorithm comes from <https://en.wikipedia.org/wiki/Exponentiation_by_squaring>
405-
///
406-
/// TODO: Still pending discussion in <https://github.com/akubera/bigdecimal-rs/issues/147>,
407-
/// we do lose a little bit of precision, and the last digits may not be correct.
408-
/// Note: This has been copied from the latest revision in <https://github.com/akubera/bigdecimal-rs/pull/148>,
409-
/// so it's using minimum Rust version of `bigdecimal-rs`.
410-
fn pow_with_context(bd: &BigDecimal, exp: i64, ctx: &Context) -> BigDecimal {
411-
if exp == 0 {
412-
return 1.into();
413-
}
414-
415-
// When performing a multiplication between 2 numbers, we may lose up to 2 digits
416-
// of precision.
417-
// "Proof": https://github.com/akubera/bigdecimal-rs/issues/147#issuecomment-2793431202
418-
const MARGIN_PER_MUL: u64 = 2;
419-
// When doing many multiplication, we still introduce additional errors, add 1 more digit
420-
// per 10 multiplications.
421-
const MUL_PER_MARGIN_EXTRA: u64 = 10;
422-
423-
fn trim_precision(bd: BigDecimal, ctx: &Context, margin: u64) -> BigDecimal {
424-
let prec = ctx.precision().get() + margin;
425-
if bd.digits() > prec {
426-
bd.with_precision_round(NonZeroU64::new(prec).unwrap(), ctx.rounding_mode())
427-
} else {
428-
bd
429-
}
430-
}
431-
432-
// Count the number of multiplications we're going to perform, one per "1" binary digit
433-
// in exp, and the number of times we can divide exp by 2.
434-
let mut n = exp.unsigned_abs();
435-
// Note: 63 - n.leading_zeros() == n.ilog2, but that's only available in recent Rust versions.
436-
let muls = (n.count_ones() + (63 - n.leading_zeros()) - 1) as u64;
437-
// Note: div_ceil would be nice to use here, but only available in recent Rust versions.
438-
// (see note above about minimum Rust version in use)
439-
let margin_extra = (muls + MUL_PER_MARGIN_EXTRA / 2) / MUL_PER_MARGIN_EXTRA;
440-
let mut margin = margin_extra + MARGIN_PER_MUL * muls;
441-
442-
let mut bd_y: BigDecimal = 1.into();
443-
let mut bd_x = if exp >= 0 {
444-
bd.clone()
445-
} else {
446-
bd.inverse_with_context(&ctx.with_precision(
447-
NonZeroU64::new(ctx.precision().get() + margin + MARGIN_PER_MUL).unwrap(),
448-
))
449-
};
450-
451-
while n > 1 {
452-
if n % 2 == 1 {
453-
bd_y = trim_precision(&bd_x * bd_y, ctx, margin);
454-
margin -= MARGIN_PER_MUL;
455-
n -= 1;
456-
}
457-
bd_x = trim_precision(bd_x.square(), ctx, margin);
458-
margin -= MARGIN_PER_MUL;
459-
n /= 2;
460-
}
461-
debug_assert_eq!(margin, margin_extra);
462-
463-
trim_precision(bd_x * bd_y, ctx, 0)
464-
}
465-
466399
/// Construct an [`ExtendedBigDecimal`] based on parsed data
467400
fn construct_extended_big_decimal(
468401
digits: BigUint,
@@ -510,7 +443,7 @@ fn construct_extended_big_decimal(
510443
let bd = BigDecimal::from_bigint(signed_digits, 0)
511444
/ BigDecimal::from_bigint(BigInt::from(16).pow(scale as u32), 0);
512445

513-
// pow_with_context "only" supports i64 values. Just overflow/underflow if the value provided
446+
// powi "only" supports i64 values. Just overflow/underflow if the value provided
514447
// is > 2**64 or < 2**-64.
515448
let Some(exponent) = exponent.to_i64() else {
516449
return Err(make_error(exponent.is_positive(), negative));
@@ -520,7 +453,7 @@ fn construct_extended_big_decimal(
520453
let base: BigDecimal = 2.into();
521454
// Note: We cannot overflow/underflow BigDecimal here, as we will not be able to reach the
522455
// maximum/minimum scale (i64 range).
523-
let pow2 = pow_with_context(&base, exponent, &Context::default());
456+
let pow2 = base.powi(exponent);
524457

525458
bd * pow2
526459
} else {

src/uucore/src/lib/features/uptime.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,8 +501,7 @@ mod tests {
501501
// (This is just a sanity check)
502502
assert!(
503503
uptime < 365 * 86400,
504-
"Uptime seems unreasonably high: {} seconds",
505-
uptime
504+
"Uptime seems unreasonably high: {uptime} seconds"
506505
);
507506
}
508507

@@ -518,9 +517,7 @@ mod tests {
518517
let diff = (uptime1 - uptime2).abs();
519518
assert!(
520519
diff <= 1,
521-
"Consecutive uptime calls should be consistent, got {} and {}",
522-
uptime1,
523-
uptime2
520+
"Consecutive uptime calls should be consistent, got {uptime1} and {uptime2}"
524521
);
525522
}
526523
}

0 commit comments

Comments
 (0)