Skip to content

Commit

Permalink
Fix build on wasm32-unknown-unknown
Browse files Browse the repository at this point in the history
Rust only allows an empty match statement in code that will not be run,
that is when matching something that is not inhabited.

References to enums are always considered inhabited, because it may
avoid some undefined behaviour in unsafe code. See
rust-lang/rust#78123

The solution in this PR is to match the enum rather than the reference
to the enum.

I also added CI for wasm32-unknown-unknown to combat regression.
  • Loading branch information
jocelyn-stericker committed Apr 25, 2021
1 parent 2bf6a47 commit 9623e55
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
20 changes: 20 additions & 0 deletions .github/workflows/ci_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,26 @@ jobs:
with:
command: test

wasm32_build:
name: Build on wasm32-unknown-unknown
steps:
- name: Checkout sources
uses: actions/checkout@v2

- name: Install stable toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
target: wasm32-unknown-unknown
override: true

- name: Run cargo test
uses: actions-rs/cargo@v1
with:
command: build
args: --target wasm32-unknown-unknown

lints:
name: Lints
runs-on: ubuntu-latest
Expand Down
4 changes: 2 additions & 2 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ pub enum CpuFeature {
impl CpuFeature {
/// Test if the given CPU feature is detected.
pub fn is_detected(&self) -> bool {
match self {
match *self {
#[cfg(target_arch = "x86_64")]
CpuFeature::Sse3 => {
is_x86_feature_detected!("sse3")
Expand All @@ -44,7 +44,7 @@ impl CpuFeature {

impl fmt::Display for CpuFeature {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
match *self {
#[cfg(target_arch = "x86_64")]
CpuFeature::Sse3 => {
write!(f, "sse3")
Expand Down

0 comments on commit 9623e55

Please sign in to comment.