Skip to content

Commit

Permalink
Default all async support to std::future
Browse files Browse the repository at this point in the history
This commit defaults all crates in-tree to use `std::future` by default
and none of them support the crates.io `futures` 0.1 crate any more.
This is a breaking change for `wasm-bindgen-futures` and
`wasm-bindgen-test` so they've both received a major version bump to
reflect the new defaults. Historical versions of these crates should
continue to work if necessary, but they won't receive any more
maintenance after this is merged.

The movement here liberally uses `async`/`await` to remove the need for
using any combinators on the `Future` trait. As a result many of the
crates now rely on a much more recent version of the compiler,
especially to run tests.

The `wasm-bindgen-futures` crate was updated to remove all of its
futures-related dependencies and purely use `std::future`, hopefully
improving its compatibility by not having any version compat
considerations over time. The implementations of the executors here are
relatively simple and only delve slightly into the `RawWaker` business
since there are no other stable APIs in `std::task` for wrapping these.

This commit also adds support for:

    #[wasm_bindgen_test]
    async fn foo() {
        // ...
    }

where previously you needed to pass `(async)` now that's inferred
because it's an `async fn`.

Closes rustwasm#1558
Closes rustwasm#1695
  • Loading branch information
alexcrichton committed Aug 28, 2019
1 parent 777828a commit 33bfe08
Show file tree
Hide file tree
Showing 32 changed files with 591 additions and 1,048 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Expand Up @@ -43,7 +43,7 @@ cfg-if = "0.1.9"

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
js-sys = { path = 'crates/js-sys', version = '0.3.27' }
wasm-bindgen-test = { path = 'crates/test', version = '=0.2.50' }
wasm-bindgen-test = { path = 'crates/test', version = '=0.3.0' }
serde_derive = "1.0"
wasm-bindgen-test-crate-a = { path = 'tests/crates/a', version = '0.1' }
wasm-bindgen-test-crate-b = { path = 'tests/crates/b', version = '0.1' }
Expand Down
19 changes: 17 additions & 2 deletions azure-pipelines.yml
Expand Up @@ -9,6 +9,8 @@ jobs:
displayName: "Run wasm-bindgen crate tests (unix)"
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: nightly
- template: ci/azure-install-node.yml
- template: ci/azure-install-geckodriver.yml
- template: ci/azure-install-sccache.yml
Expand Down Expand Up @@ -48,6 +50,8 @@ jobs:
vmImage: vs2017-win2016
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: nightly
- template: ci/azure-install-node.yml
- template: ci/azure-install-geckodriver.yml
- template: ci/azure-install-sccache.yml
Expand Down Expand Up @@ -91,6 +95,8 @@ jobs:
displayName: "Run web-sys crate tests"
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: nightly
- template: ci/azure-install-node.yml
- template: ci/azure-install-geckodriver.yml
- template: ci/azure-install-sccache.yml
Expand All @@ -104,6 +110,8 @@ jobs:
displayName: "Run js-sys crate tests"
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: nightly
- template: ci/azure-install-node.yml
- template: ci/azure-install-geckodriver.yml
- template: ci/azure-install-sccache.yml
Expand All @@ -113,6 +121,8 @@ jobs:
displayName: "Run wasm-bindgen-webidl crate tests"
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: nightly
- template: ci/azure-install-node.yml
#- template: ci/azure-install-sccache.yml
- script: cargo test -p wasm-bindgen-webidl
Expand All @@ -125,7 +135,7 @@ jobs:
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: beta
toolchain: nightly
- template: ci/azure-install-node.yml
- template: ci/azure-install-sccache.yml
- script: cargo test -p wasm-bindgen-macro
Expand Down Expand Up @@ -156,6 +166,8 @@ jobs:
displayName: "Build almost all examples"
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: nightly
- template: ci/azure-install-sccache.yml
- template: ci/azure-install-wasm-pack.yml
- script: mv _package.json package.json && npm install && rm package.json
Expand Down Expand Up @@ -198,6 +210,8 @@ jobs:
displayName: "Build benchmarks"
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: nightly
- template: ci/azure-install-sccache.yml
- template: ci/azure-install-wasm-pack.yml
- script: wasm-pack build --target web benchmarks
Expand Down Expand Up @@ -263,7 +277,6 @@ jobs:
- job: doc_book
displayName: "Doc - build the book"
steps:
- template: ci/azure-install-rust.yml
- script: |
set -e
curl -L https://github.com/rust-lang-nursery/mdBook/releases/download/v0.3.0/mdbook-v0.3.0-x86_64-unknown-linux-gnu.tar.gz | tar xzf -
Expand All @@ -279,6 +292,8 @@ jobs:
displayName: "Doc - build the API documentation"
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: nightly
# Install rustfmt so we can format the web-sys bindings
- script: rustup component add rustfmt
displayName: "Install rustfmt"
Expand Down
11 changes: 2 additions & 9 deletions crates/futures/Cargo.toml
Expand Up @@ -7,17 +7,13 @@ license = "MIT/Apache-2.0"
name = "wasm-bindgen-futures"
repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/futures"
readme = "./README.md"
version = "0.3.27"
version = "0.4.0"
edition = "2018"

[dependencies]
cfg-if = "0.1.9"
futures = "0.1.20"
js-sys = { path = "../js-sys", version = '0.3.27' }
wasm-bindgen = { path = "../..", version = '0.2.50' }
futures-util-preview = { version = "0.3.0-alpha.18", optional = true }
futures-channel-preview = { version = "0.3.0-alpha.18", optional = true }
lazy_static = { version = "1.3.0", optional = true }

[target.'cfg(target_feature = "atomics")'.dependencies.web-sys]
path = "../web-sys"
Expand All @@ -28,7 +24,4 @@ features = [
]

[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
wasm-bindgen-test = { path = '../test', version = '0.2.50' }

[features]
futures_0_3 = ["futures-util-preview", "futures-channel-preview", "lazy_static"]
wasm-bindgen-test = { path = '../test', version = '0.3.0' }

0 comments on commit 33bfe08

Please sign in to comment.