Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix wasm_bindgen_futures not using custom path #3602

Merged
merged 1 commit into from
Sep 13, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,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 @@ -110,6 +112,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