From 744dda8ecf83fb894b16181458e45ac3c45ddbd3 Mon Sep 17 00:00:00 2001 From: jedel1043 Date: Fri, 17 Nov 2023 01:24:35 -0600 Subject: [PATCH] Fix last warnings --- .github/workflows/rust.yml | 10 ++- boa_engine/src/builtins/options.rs | 97 +++++++++++++++--------------- 2 files changed, 58 insertions(+), 49 deletions(-) diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index da509592787..9c51af9ba9b 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -122,9 +122,15 @@ jobs: with: key: clippy - name: Clippy (All features) - run: cargo workspaces exec cargo clippy --all-features --all-targets -- -D warnings + run: cargo workspaces exec cargo clippy --all-features --all-targets - name: Clippy (No features) - run: cargo workspaces exec cargo clippy --no-default-features --all-targets -- -D warnings + run: cargo workspaces exec cargo clippy --no-default-features --all-targets + - name: Clippy (Intl) + run: cargo clippy -p boa_engine --features intl + - name: Clippy (Annex-B) + run: cargo clippy -p boa_engine --features annex-b + - name: Clippy (Experimental) + run: cargo clippy -p boa_engine --features experimental docs: name: Documentation diff --git a/boa_engine/src/builtins/options.rs b/boa_engine/src/builtins/options.rs index b2a99f5559a..4628f0eee4b 100644 --- a/boa_engine/src/builtins/options.rs +++ b/boa_engine/src/builtins/options.rs @@ -124,53 +124,6 @@ pub(crate) enum RoundingMode { HalfEven, } -#[derive(Debug, Clone, Copy, PartialEq, Eq)] -pub(crate) enum UnsignedRoundingMode { - Infinity, - Zero, - HalfInfinity, - HalfZero, - HalfEven, -} - -impl RoundingMode { - pub(crate) const fn negate(self) -> Self { - use RoundingMode::{ - Ceil, Expand, Floor, HalfCeil, HalfEven, HalfExpand, HalfFloor, HalfTrunc, Trunc, - }; - - match self { - Ceil => Self::Floor, - Floor => Self::Ceil, - HalfCeil => Self::HalfFloor, - HalfFloor => Self::HalfCeil, - Trunc => Self::Trunc, - Expand => Self::Expand, - HalfTrunc => Self::HalfTrunc, - HalfExpand => Self::HalfExpand, - HalfEven => Self::HalfEven, - } - } - - pub(crate) const fn get_unsigned_round_mode(self, is_negative: bool) -> UnsignedRoundingMode { - use RoundingMode::{ - Ceil, Expand, Floor, HalfCeil, HalfEven, HalfExpand, HalfFloor, HalfTrunc, Trunc, - }; - - match self { - Ceil if !is_negative => UnsignedRoundingMode::Infinity, - Ceil => UnsignedRoundingMode::Zero, - Floor if !is_negative => UnsignedRoundingMode::Zero, - Floor | Trunc | Expand => UnsignedRoundingMode::Infinity, - HalfCeil if !is_negative => UnsignedRoundingMode::HalfInfinity, - HalfCeil | HalfTrunc => UnsignedRoundingMode::HalfZero, - HalfFloor if !is_negative => UnsignedRoundingMode::HalfZero, - HalfFloor | HalfExpand => UnsignedRoundingMode::HalfInfinity, - HalfEven => UnsignedRoundingMode::HalfEven, - } - } -} - #[derive(Debug)] pub(crate) struct ParseRoundingModeError; @@ -217,3 +170,53 @@ impl fmt::Display for RoundingMode { .fmt(f) } } + +#[cfg(feature = "temporal")] +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub(crate) enum UnsignedRoundingMode { + Infinity, + Zero, + HalfInfinity, + HalfZero, + HalfEven, +} + +impl RoundingMode { + #[cfg(feature = "temporal")] + pub(crate) const fn negate(self) -> Self { + use RoundingMode::{ + Ceil, Expand, Floor, HalfCeil, HalfEven, HalfExpand, HalfFloor, HalfTrunc, Trunc, + }; + + match self { + Ceil => Self::Floor, + Floor => Self::Ceil, + HalfCeil => Self::HalfFloor, + HalfFloor => Self::HalfCeil, + Trunc => Self::Trunc, + Expand => Self::Expand, + HalfTrunc => Self::HalfTrunc, + HalfExpand => Self::HalfExpand, + HalfEven => Self::HalfEven, + } + } + + #[cfg(feature = "temporal")] + pub(crate) const fn get_unsigned_round_mode(self, is_negative: bool) -> UnsignedRoundingMode { + use RoundingMode::{ + Ceil, Expand, Floor, HalfCeil, HalfEven, HalfExpand, HalfFloor, HalfTrunc, Trunc, + }; + + match self { + Ceil if !is_negative => UnsignedRoundingMode::Infinity, + Ceil => UnsignedRoundingMode::Zero, + Floor if !is_negative => UnsignedRoundingMode::Zero, + Floor | Trunc | Expand => UnsignedRoundingMode::Infinity, + HalfCeil if !is_negative => UnsignedRoundingMode::HalfInfinity, + HalfCeil | HalfTrunc => UnsignedRoundingMode::HalfZero, + HalfFloor if !is_negative => UnsignedRoundingMode::HalfZero, + HalfFloor | HalfExpand => UnsignedRoundingMode::HalfInfinity, + HalfEven => UnsignedRoundingMode::HalfEven, + } + } +}