Skip to content

Commit

Permalink
Fix wasm_bindgen_futures not using custom path
Browse files Browse the repository at this point in the history
  • Loading branch information
daxpedda committed Sep 7, 2023
1 parent 4b8aecf commit 86fcd58
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@
* Add bindings for `WebAssembly.Tag` and `WebAssembly.Exception`.
[#3484](https://github.com/rustwasm/wasm-bindgen/pull/3484)

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

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

* Add bindings for async variants of `Atomics.wait`.
[#3504](https://github.com/rustwasm/wasm-bindgen/pull/3504)
Expand Down Expand Up @@ -93,6 +95,11 @@
* Fixed optional parameters in JSDoc.
[#3577](https://github.com/rustwasm/wasm-bindgen/pull/3577)

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

### Removed

* Removed `ReadableStreamByobReader::read_with_u8_array()` because it doesn't work with Wasm.
Expand Down
8 changes: 4 additions & 4 deletions crates/backend/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1190,11 +1190,11 @@ impl TryToTokens for ast::ImportFunction {
Some(ref ty) => {
if self.function.r#async {
abi_ret = quote! {
#wasm_bindgen::convert::WasmRet<<js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>::Abi>
#wasm_bindgen::convert::WasmRet<<#wasm_bindgen_futures::js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>::Abi>
};
let future = quote! {
#wasm_bindgen_futures::JsFuture::from(
<js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>
<#wasm_bindgen_futures::js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>
::from_abi(#ret_ident.join())
).await
};
Expand All @@ -1216,11 +1216,11 @@ impl TryToTokens for ast::ImportFunction {
None => {
if self.function.r#async {
abi_ret = quote! {
#wasm_bindgen::convert::WasmRet<<js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>::Abi>
#wasm_bindgen::convert::WasmRet<<#wasm_bindgen_futures::js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>::Abi>
};
let future = quote! {
#wasm_bindgen_futures::JsFuture::from(
<js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>
<#wasm_bindgen_futures::js_sys::Promise as #wasm_bindgen::convert::FromWasmAbi>
::from_abi(#ret_ident.join())
).await
};
Expand Down
3 changes: 3 additions & 0 deletions crates/futures/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ mod queue;
#[cfg(feature = "futures-core-03-stream")]
pub mod stream;

pub use js_sys;
pub use wasm_bindgen;

mod task {
use cfg_if::cfg_if;

Expand Down
8 changes: 4 additions & 4 deletions crates/macro/ui-tests/async-errors.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ error[E0277]: the trait bound `wasm_bindgen::JsValue: From<BadType>` is not sati
<wasm_bindgen::JsValue as From<&'a str>>
<wasm_bindgen::JsValue as From<*const T>>
<wasm_bindgen::JsValue as From<*mut T>>
<wasm_bindgen::JsValue as From<JsError>>
<wasm_bindgen::JsValue as From<MyType>>
<wasm_bindgen::JsValue as From<Option<T>>>
and 74 others
<wasm_bindgen::JsValue as From<Array>>
<wasm_bindgen::JsValue as From<ArrayBuffer>>
<wasm_bindgen::JsValue as From<BigInt64Array>>
and $N others
= note: required for `BadType` to implement `Into<wasm_bindgen::JsValue>`
= note: required for `BadType` to implement `IntoJsResult`
= note: this error originates in the attribute macro `wasm_bindgen` (in Nightly builds, run with -Z macro-backtrace for more info)
Expand Down

0 comments on commit 86fcd58

Please sign in to comment.