Skip to content

Commit

Permalink
Default all async support to std::future (#1741)
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 #1558
Closes #1695
  • Loading branch information
alexcrichton authored Sep 5, 2019
1 parent ba85275 commit 3c887c4
Show file tree
Hide file tree
Showing 33 changed files with 643 additions and 1,120 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
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
30 changes: 27 additions & 3 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ jobs:
displayName: "Run wasm-bindgen crate tests (unix)"
steps:
- template: ci/azure-install-rust.yml
# TODO: switch this back to `stable` when async/await is stable
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 +51,9 @@ jobs:
vmImage: vs2017-win2016
steps:
- template: ci/azure-install-rust.yml
# TODO: switch this back to `stable` when async/await is stable
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 +97,9 @@ jobs:
displayName: "Run web-sys crate tests"
steps:
- template: ci/azure-install-rust.yml
# TODO: switch this back to `stable` when async/await is stable
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 +113,9 @@ jobs:
displayName: "Run js-sys crate tests"
steps:
- template: ci/azure-install-rust.yml
# TODO: switch this back to `stable` when async/await is stable
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 +125,9 @@ jobs:
displayName: "Run wasm-bindgen-webidl crate tests"
steps:
- template: ci/azure-install-rust.yml
# TODO: switch this back to `stable` when async/await is stable
parameters:
toolchain: nightly
- template: ci/azure-install-node.yml
#- template: ci/azure-install-sccache.yml
- script: cargo test -p wasm-bindgen-webidl
Expand All @@ -124,8 +139,9 @@ jobs:
displayName: "Run UI tests"
steps:
- template: ci/azure-install-rust.yml
# TODO: switch this back to `stable` when async/await is stable
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 +172,9 @@ jobs:
displayName: "Build almost all examples"
steps:
- template: ci/azure-install-rust.yml
# TODO: switch this back to `stable` when async/await is stable
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 All @@ -177,7 +196,7 @@ jobs:
steps:
- template: ci/azure-install-rust.yml
parameters:
toolchain: nightly-2019-07-30
toolchain: nightly-2019-08-27
- template: ci/azure-install-sccache.yml
- script: rustup component add rust-src
displayName: "install rust-src"
Expand All @@ -198,6 +217,9 @@ jobs:
displayName: "Build benchmarks"
steps:
- template: ci/azure-install-rust.yml
# TODO: switch this back to `stable` when async/await is stable
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 +285,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 +300,9 @@ jobs:
displayName: "Doc - build the API documentation"
steps:
- template: ci/azure-install-rust.yml
# TODO: switch this back to `stable` when async/await is stable
parameters:
toolchain: nightly
# Install rustfmt so we can format the web-sys bindings
- script: rustup component add rustfmt
displayName: "Install rustfmt"
Expand Down
12 changes: 3 additions & 9 deletions crates/futures/Cargo.toml
Original file line number Diff line number Diff line change
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,5 @@ 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' }
futures-channel-preview = { version = "0.3.0-alpha.18" }
Loading

0 comments on commit 3c887c4

Please sign in to comment.