diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 1b874f728..0555b2880 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -94,6 +94,62 @@ jobs: command: check args: --no-default-features --features serde,rand --target thumbv7em-none-eabihf + check-web: + name: Type checking (web) + runs-on: ubuntu-latest + strategy: + matrix: + rust: [1.32.0, 1.36.0, stable] # 1.36 is when alloc was stabilized + + steps: + - name: Checkout sources + uses: actions/checkout@v2 + + - name: Install cargo-web + uses: actions-rs/install@v0.1 + with: + crate: cargo-web + use-tool-cache: true + + - name: Cache target + uses: actions/cache@v1 + env: + cache-name: target + with: + path: ./target + key: ubuntu-latest-typecheck-target-${{ matrix.rust }}-web + + - name: Install toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.rust }} + target: wasm32-unknown-unknown + override: true + + # ensure `#![no_std]` support + - name: Run `cargo web check --no-default-features` + uses: actions-rs/cargo@v1 + with: + command: web + args: check --no-default-features + if: matrix.rust != '1.32.0' # alloc is unstable in 1.32 + + # `#![no_std]` with serde, rand + - name: Run `cargo web check --no-default-features --features serde,rand` + uses: actions-rs/cargo@v1 + with: + command: web + args: check --no-default-features --features serde,rand + if: matrix.rust != '1.32.0' # alloc is unstable in 1.32 + + # everything + - name: Run `cargo check --features serde,deprecated,panicking-api,rand` + uses: actions-rs/cargo@v1 + with: + command: check + args: --features serde,deprecated,panicking-api,rand + test: name: Test suite runs-on: ${{ matrix.os }} @@ -191,7 +247,7 @@ jobs: name: Documentation runs-on: ubuntu-latest # ensure docs only get pushed if everything else is successful - needs: [check, test, fmt, clippy] + needs: [check, check-embedded, check-web, test, fmt, clippy] steps: - name: Checkout diff --git a/src/utc_offset.rs b/src/utc_offset.rs index 5ec07676a..e77755dc7 100644 --- a/src/utc_offset.rs +++ b/src/utc_offset.rs @@ -3,8 +3,6 @@ use crate::{ internal_prelude::*, }; use core::fmt::{self, Display}; -#[cfg(cargo_web)] -use stdweb::js; /// An offset from UTC. /// @@ -490,7 +488,7 @@ fn try_local_offset_at(datetime: OffsetDateTime) -> Option { diff_secs.try_into().ok().map(UtcOffset::seconds) } else if #[cfg(cargo_web)] { - use stdweb::unstable::TryInto; + use stdweb::js; let timestamp_utc = datetime.timestamp(); let low_bits = (timestamp_utc & 0xFF_FF_FF_FF) as i32; @@ -502,7 +500,7 @@ fn try_local_offset_at(datetime: OffsetDateTime) -> Option { .getTimezoneOffset() * -60; }; - timezone_offset.try_into().ok().map(UtcOffset::seconds) + stdweb::unstable::TryInto::try_into(timezone_offset).ok().map(UtcOffset::seconds) } else { None }