Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose features from rand to avoid compilation breakage on WASM #1804

Closed
wants to merge 1 commit into from

Commits on Aug 14, 2019

  1. Expose features from rand to avoid compilation breakage on WASM

    Current error:
    ```
    error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
       --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.1.9/src/lib.rs:249:9
        |
    249 | /         compile_error!("\
    250 | |             target is not supported, for more information see: \
    251 | |             https://docs.rs/getrandom/#unsupported-targets\
    252 | |         ");
        | |___________^
    ```
    
    In order to use `join!` and `select!` macros, we require the user to enable the
    `async-await` and `nightly` features. However those features will pull in
    rand. In order to work on WASM rand needs to have either the `wasm-bindgen`
    or `stdweb` feature enabled. Otherwise compile time breakage happens due to the
    `getrandom` crate.
    
    Explanation can be found here: https://docs.rs/getrandom/0.1.9/getrandom/#unsupported-targets
    
    This commit exposes those features through `futures-util`, allowing the end user to enable them
    when compiling on WASM. This means futures does not need to choose which feature to enable
    which would take away that decision from the end user.
    
    An alternative would be to detect the wasm32 target in Cargo.toml and to choose
    one of the features automatically.
    
    Current approach requires action on part of the user to enable one of those features,
    which means it should probably be documented somewhere. Currently the documentation
    of `join!` and `select!` does not mention the need for the `async-await` and `nightly`
    features.
    
    I propose we add some documentation changes to this PR before merging.
    
    On some quick testing this alleviates the compile error on my system, but it would
    be good if someone else had a look, or if we had CI testing for WASM.
    najamelan committed Aug 14, 2019
    Configuration menu
    Copy the full SHA
    ad0a059 View commit details
    Browse the repository at this point in the history