Skip to content

Compilation failure on wasm32-unknown-emscripten: platform_impl is defined multiple times and type mismatch in into_abi #963

@tomast1337

Description

@tomast1337

When compiling a Rust project using cpal for wasm32-unknown-emscripten, the build fails due to multiple errors:

  1. Duplicate module definition (E0428):

    error[E0428]: the name `platform_impl` is defined multiple times
    --> cpal-0.15.3/src/platform/mod.rs:640:1
    622 | mod platform_impl {
    | ----------------- previous definition of the module `platform_impl` here
    ...
    640 | mod platform_impl {
    | ^^^^^^^^^^^^^^^^^ `platform_impl` redefined here
    

    It seems like platform_impl is being defined twice, likely due to conditional compilation issues.

  2. Type mismatch (E0308) in into_abi function:

    error[E0308]: mismatched types
    --> cpal-0.15.3/src/lib.rs:248:9
    247 | fn into_abi(self) -> Self::Abi {
    |                      --------- expected `Option<u32>` because of return type
    248 | match self {
    249 | Self::Default => None,
    250 | Self::Fixed(fc) => Some(fc),
    251 | }
    252 | .into_abi()
    | ___________________^ expected `Option<u32>`, found `f64`
    

    The into_abi() function appears to be returning a f64, whereas the expected type is Option<u32>.


Steps to Reproduce:

  1. Create a Rust project with cpal = "0.15.3" in Cargo.toml.

    cargo new --bin cpal_test
    cd cpal_test
    cargo add cpal --version 0.15.3
  2. Compile using:

    cargo build --release --target=wasm32-unknown-emscripten
  3. Observe the errors.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions