Fix wasm_bindgen_futures not using custom path (#3602)

This commit is contained in:
daxpedda 2023-09-13 10:34:53 +02:00 committed by GitHub
parent 51e89ebee5
commit e7c760fb3c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 20 additions and 10 deletions

View File

@ -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)
@ -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.

View File

@ -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
};
@ -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
};

View File

@ -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;

View File

@ -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)