Skip to content

Commit 6167a79

Browse files
committed
Fix wasm_bindgen_futures not using custom path
1 parent 51e89eb commit 6167a79

File tree

4 files changed

+20
-10
lines changed

4 files changed

+20
-10
lines changed

CHANGELOG.md

+9-2
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
* Add bindings for `WebAssembly.Tag` and `WebAssembly.Exception`.
1515
[#3484](https://github.com/rustwasm/wasm-bindgen/pull/3484)
1616

17-
* Re-export `wasm-bindgen` from `js-sys` and `web-sys`.
17+
* Re-export `wasm-bindgen` from `js-sys`, `web-sys` and `wasm-bindgen-futures`.
1818
[#3466](https://github.com/rustwasm/wasm-bindgen/pull/3466)
19+
[#3601](https://github.com/rustwasm/wasm-bindgen/pull/3601)
1920

20-
* Re-export `js-sys` from `web-sys`.
21+
* Re-export `js-sys` from `web-sys` and `wasm-bindgen-futures`.
2122
[#3466](https://github.com/rustwasm/wasm-bindgen/pull/3466)
23+
[#3601](https://github.com/rustwasm/wasm-bindgen/pull/3601)
2224

2325
* Add bindings for async variants of `Atomics.wait`.
2426
[#3504](https://github.com/rustwasm/wasm-bindgen/pull/3504)
@@ -110,6 +112,11 @@
110112
* Fixed optional parameters in JSDoc.
111113
[#3577](https://github.com/rustwasm/wasm-bindgen/pull/3577)
112114

115+
* Use re-exported `js-sys` from `wasm-bindgen-futures` to account for
116+
non-default path specified by the `crate` attribute in `wasm_bindgen_futures`
117+
proc-macro.
118+
[#3601](https://github.com/rustwasm/wasm-bindgen/pull/3601)
119+
113120
### Removed
114121

115122
* Removed `ReadableStreamByobReader::read_with_u8_array()` because it doesn't work with Wasm.

crates/backend/src/codegen.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1190,11 +1190,11 @@ impl TryToTokens for ast::ImportFunction {
11901190
Some(ref ty) => {
11911191
if self.function.r#async {
11921192
abi_ret = quote! {
1193-
#wasm_bindgen::convert::WasmRet<<js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>::Abi>
1193+
#wasm_bindgen::convert::WasmRet<<#wasm_bindgen_futures::js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>::Abi>
11941194
};
11951195
let future = quote! {
11961196
#wasm_bindgen_futures::JsFuture::from(
1197-
<js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>
1197+
<#wasm_bindgen_futures::js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>
11981198
::from_abi(#ret_ident.join())
11991199
).await
12001200
};
@@ -1216,11 +1216,11 @@ impl TryToTokens for ast::ImportFunction {
12161216
None => {
12171217
if self.function.r#async {
12181218
abi_ret = quote! {
1219-
#wasm_bindgen::convert::WasmRet<<js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>::Abi>
1219+
#wasm_bindgen::convert::WasmRet<<#wasm_bindgen_futures::js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>::Abi>
12201220
};
12211221
let future = quote! {
12221222
#wasm_bindgen_futures::JsFuture::from(
1223-
<js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>
1223+
<#wasm_bindgen_futures::js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>
12241224
::from_abi(#ret_ident.join())
12251225
).await
12261226
};

crates/futures/src/lib.rs

+3
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,9 @@ mod queue;
4646
#[cfg(feature = "futures-core-03-stream")]
4747
pub mod stream;
4848

49+
pub use js_sys;
50+
pub use wasm_bindgen;
51+
4952
mod task {
5053
use cfg_if::cfg_if;
5154

crates/macro/ui-tests/async-errors.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ error[E0277]: the trait bound `wasm_bindgen::JsValue: From<BadType>` is not sati
3232
<wasm_bindgen::JsValue as From<&'a str>>
3333
<wasm_bindgen::JsValue as From<*const T>>
3434
<wasm_bindgen::JsValue as From<*mut T>>
35-
<wasm_bindgen::JsValue as From<JsError>>
36-
<wasm_bindgen::JsValue as From<MyType>>
37-
<wasm_bindgen::JsValue as From<Option<T>>>
38-
and 74 others
35+
<wasm_bindgen::JsValue as From<Array>>
36+
<wasm_bindgen::JsValue as From<ArrayBuffer>>
37+
<wasm_bindgen::JsValue as From<BigInt64Array>>
38+
and $N others
3939
= note: required for `BadType` to implement `Into<wasm_bindgen::JsValue>`
4040
= note: required for `BadType` to implement `IntoJsResult`
4141
= note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)