From a53276db6cca7af25c7a9e0009ae9f6ba89022da Mon Sep 17 00:00:00 2001 From: Matt Keeter Date: Sun, 14 Apr 2024 20:55:11 -0400 Subject: [PATCH] Run cargo build against `wasm32-unknown-unknown` target to catch MIR failures (#86) https://github.com/rust-lang/rust/issues/49292 --- .github/workflows/check-wasm.yml | 4 +++- Cargo.lock | 2 +- fidget/src/mesh/cell.rs | 2 ++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/.github/workflows/check-wasm.yml b/.github/workflows/check-wasm.yml index e509cbc3..0717fd69 100644 --- a/.github/workflows/check-wasm.yml +++ b/.github/workflows/check-wasm.yml @@ -23,4 +23,6 @@ jobs: - name: Install wasm target run: rustup target add ${{ matrix.target }} - name: Check - run: cargo check --target=${{ matrix.target }} -pfidget --no-default-features --features="rhai,render,mesh" + # cargo check doesn't find MIR diagnostics, so we use cargo build instead + # (https://github.com/rust-lang/rust/issues/49292) + run: cargo build --target=${{ matrix.target }} -pfidget --no-default-features --features="rhai,render,mesh" diff --git a/Cargo.lock b/Cargo.lock index 001e7afc..fd9bea5d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -877,7 +877,7 @@ dependencies = [ [[package]] name = "fidget" -version = "0.2.5" +version = "0.2.6" dependencies = [ "arrayvec", "bimap", diff --git a/fidget/src/mesh/cell.rs b/fidget/src/mesh/cell.rs index 5bf71ec0..2685b74c 100644 --- a/fidget/src/mesh/cell.rs +++ b/fidget/src/mesh/cell.rs @@ -19,10 +19,12 @@ impl From for CellData { Cell::Empty => 1, Cell::Full => 2, Cell::Branch { index, thread } => { + #[cfg(not(target_arch = "wasm32"))] debug_assert!(index < (1 << 54)); 0b10 << 62 | ((thread as u64) << 54) | index as u64 } Cell::Leaf(Leaf { mask, index }) => { + #[cfg(not(target_arch = "wasm32"))] debug_assert!(index < (1 << 54)); (0b11 << 62) | ((mask as u64) << 54) | index as u64 }