From 9b2388827c27472bdd21c8ba49ceb9840c4ba1d7 Mon Sep 17 00:00:00 2001 From: nathaniel-daniel <80441888+nathaniel-daniel@users.noreply.github.com> Date: Tue, 3 Oct 2023 19:38:36 -0700 Subject: [PATCH] Fix clippy (#21) --- .github/workflows/Build.yml | 2 +- src/file_time.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/Build.yml b/.github/workflows/Build.yml index 0a6e3a9..2ba8ce7 100644 --- a/.github/workflows/Build.yml +++ b/.github/workflows/Build.yml @@ -67,7 +67,7 @@ jobs: key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }} - name: Install wasm-pack - run: cargo install wasm-pack + run: cargo install wasm-pack --force - name: Build run: cargo build --all --verbose diff --git a/src/file_time.rs b/src/file_time.rs index 4ee2944..66ec841 100644 --- a/src/file_time.rs +++ b/src/file_time.rs @@ -1,4 +1,4 @@ -#![warn(clippy::integer_arithmetic)] +#![warn(clippy::arithmetic_side_effects)] use std::time::Duration; use std::time::SystemTime; @@ -109,9 +109,8 @@ impl TryFrom for SystemTime { .map_err(|_| TryFromFileTimeError::Unspecified)?; let offset_seconds = Duration::from_secs(secs_part); // 0 < the # of nanoseonds in a second < u64::MAX - // Clippy: I don't think this can overflow/panic fo u64s. - #[allow(clippy::integer_arithmetic)] - let nanos_part = u64::try_from(nanos % u128::from(NANOSECONDS_PER_SECOND)).unwrap(); + let nanos_part = + u64::try_from(nanos.rem_euclid(u128::from(NANOSECONDS_PER_SECOND))).unwrap(); let offset_nanos = Duration::from_nanos(nanos_part); let offset = offset_seconds .checked_add(offset_nanos)