Skip to content

Commit 3c887c4

Browse files
authored
Default all async support to std::future (#1741)
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
1 parent ba85275 commit 3c887c4

33 files changed

+643
-1120
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ cfg-if = "0.1.9"
4343

4444
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
4545
js-sys = { path = 'crates/js-sys', version = '0.3.27' }
46-
wasm-bindgen-test = { path = 'crates/test', version = '=0.2.50' }
46+
wasm-bindgen-test = { path = 'crates/test', version = '=0.3.0' }
4747
serde_derive = "1.0"
4848
wasm-bindgen-test-crate-a = { path = 'tests/crates/a', version = '0.1' }
4949
wasm-bindgen-test-crate-b = { path = 'tests/crates/b', version = '0.1' }

azure-pipelines.yml

+27-3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ jobs:
99
displayName: "Run wasm-bindgen crate tests (unix)"
1010
steps:
1111
- template: ci/azure-install-rust.yml
12+
# TODO: switch this back to `stable` when async/await is stable
13+
parameters:
14+
toolchain: nightly
1215
- template: ci/azure-install-node.yml
1316
- template: ci/azure-install-geckodriver.yml
1417
- template: ci/azure-install-sccache.yml
@@ -48,6 +51,9 @@ jobs:
4851
vmImage: vs2017-win2016
4952
steps:
5053
- template: ci/azure-install-rust.yml
54+
# TODO: switch this back to `stable` when async/await is stable
55+
parameters:
56+
toolchain: nightly
5157
- template: ci/azure-install-node.yml
5258
- template: ci/azure-install-geckodriver.yml
5359
- template: ci/azure-install-sccache.yml
@@ -91,6 +97,9 @@ jobs:
9197
displayName: "Run web-sys crate tests"
9298
steps:
9399
- template: ci/azure-install-rust.yml
100+
# TODO: switch this back to `stable` when async/await is stable
101+
parameters:
102+
toolchain: nightly
94103
- template: ci/azure-install-node.yml
95104
- template: ci/azure-install-geckodriver.yml
96105
- template: ci/azure-install-sccache.yml
@@ -104,6 +113,9 @@ jobs:
104113
displayName: "Run js-sys crate tests"
105114
steps:
106115
- template: ci/azure-install-rust.yml
116+
# TODO: switch this back to `stable` when async/await is stable
117+
parameters:
118+
toolchain: nightly
107119
- template: ci/azure-install-node.yml
108120
- template: ci/azure-install-geckodriver.yml
109121
- template: ci/azure-install-sccache.yml
@@ -113,6 +125,9 @@ jobs:
113125
displayName: "Run wasm-bindgen-webidl crate tests"
114126
steps:
115127
- template: ci/azure-install-rust.yml
128+
# TODO: switch this back to `stable` when async/await is stable
129+
parameters:
130+
toolchain: nightly
116131
- template: ci/azure-install-node.yml
117132
#- template: ci/azure-install-sccache.yml
118133
- script: cargo test -p wasm-bindgen-webidl
@@ -124,8 +139,9 @@ jobs:
124139
displayName: "Run UI tests"
125140
steps:
126141
- template: ci/azure-install-rust.yml
142+
# TODO: switch this back to `stable` when async/await is stable
127143
parameters:
128-
toolchain: beta
144+
toolchain: nightly
129145
- template: ci/azure-install-node.yml
130146
- template: ci/azure-install-sccache.yml
131147
- script: cargo test -p wasm-bindgen-macro
@@ -156,6 +172,9 @@ jobs:
156172
displayName: "Build almost all examples"
157173
steps:
158174
- template: ci/azure-install-rust.yml
175+
# TODO: switch this back to `stable` when async/await is stable
176+
parameters:
177+
toolchain: nightly
159178
- template: ci/azure-install-sccache.yml
160179
- template: ci/azure-install-wasm-pack.yml
161180
- script: mv _package.json package.json && npm install && rm package.json
@@ -177,7 +196,7 @@ jobs:
177196
steps:
178197
- template: ci/azure-install-rust.yml
179198
parameters:
180-
toolchain: nightly-2019-07-30
199+
toolchain: nightly-2019-08-27
181200
- template: ci/azure-install-sccache.yml
182201
- script: rustup component add rust-src
183202
displayName: "install rust-src"
@@ -198,6 +217,9 @@ jobs:
198217
displayName: "Build benchmarks"
199218
steps:
200219
- template: ci/azure-install-rust.yml
220+
# TODO: switch this back to `stable` when async/await is stable
221+
parameters:
222+
toolchain: nightly
201223
- template: ci/azure-install-sccache.yml
202224
- template: ci/azure-install-wasm-pack.yml
203225
- script: wasm-pack build --target web benchmarks
@@ -263,7 +285,6 @@ jobs:
263285
- job: doc_book
264286
displayName: "Doc - build the book"
265287
steps:
266-
- template: ci/azure-install-rust.yml
267288
- script: |
268289
set -e
269290
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 -
@@ -279,6 +300,9 @@ jobs:
279300
displayName: "Doc - build the API documentation"
280301
steps:
281302
- template: ci/azure-install-rust.yml
303+
# TODO: switch this back to `stable` when async/await is stable
304+
parameters:
305+
toolchain: nightly
282306
# Install rustfmt so we can format the web-sys bindings
283307
- script: rustup component add rustfmt
284308
displayName: "Install rustfmt"

crates/futures/Cargo.toml

+3-9
Original file line numberDiff line numberDiff line change
@@ -7,17 +7,13 @@ license = "MIT/Apache-2.0"
77
name = "wasm-bindgen-futures"
88
repository = "https://github.com/rustwasm/wasm-bindgen/tree/master/crates/futures"
99
readme = "./README.md"
10-
version = "0.3.27"
10+
version = "0.4.0"
1111
edition = "2018"
1212

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

2218
[target.'cfg(target_feature = "atomics")'.dependencies.web-sys]
2319
path = "../web-sys"
@@ -28,7 +24,5 @@ features = [
2824
]
2925

3026
[target.'cfg(target_arch = "wasm32")'.dev-dependencies]
31-
wasm-bindgen-test = { path = '../test', version = '0.2.50' }
32-
33-
[features]
34-
futures_0_3 = ["futures-util-preview", "futures-channel-preview", "lazy_static"]
27+
wasm-bindgen-test = { path = '../test', version = '0.3.0' }
28+
futures-channel-preview = { version = "0.3.0-alpha.18" }

0 commit comments

Comments
 (0)