seed-rs / seed

A Rust framework for creating web apps
MIT License
3.81k stars 155 forks source link

Does not build with wasm-bindgen 0.2.81 #687

Closed ndarilek closed 2 years ago

ndarilek commented 2 years ago

Hello,

I'm using Seed for a wasm example in one of my projects, and noticed that it no longer builds with wasm-bindgen 0.2.81. 0.2.80 works fine. To duplicate, check out master, run cargo update && cargo build. The errors:

Compiling seed v0.9.1 (C:\Users\Nolan\src\seed)
error[E0283]: type annotations needed for Closure<T>
--> src\browser\service\routing.rs:87:19
87 let closure = Closure::new(move event: web_sys::Event { ------- ^^^^^^^^^^^^ cannot infer type for type parameter T
consider giving closure the explicit type Closure<T>, where the type parameter T is specified
= note: cannot satisfy `_: WasmClosure`                                                                                                                                   
note: required by a bound in Closure::<T>::new
--> C:\Users\Nolan\scoop\persist\rustup.cargo\registry\src\github.com-1ecc6299db9ec823\wasm-bindgen-0.2.81\src\closure.rs:251:17
251 T: ?Sized + WasmClosure, ^^^^^^^^^^^ required by this bound in Closure::<T>::new
help: consider specifying the type argument in the function call
87 let closure = Closure::new::(move event: web_sys::Event {
+++++
error[E0283]: type annotations needed for Closure<T>
--> src\browser\service\routing.rs:87:19
87 let closure = Closure::new(move event: web_sys::Event { ------- ^^^^^^^^^^^^ cannot infer type for type parameter T
consider giving closure the explicit type Closure<T>, where the type parameter T is specified
= note: multiple `impl`s satisfying `[closure@src\browser\service\routing.rs:87:32: 126:6]: IntoWasmClosure<_>` found in the `wasm_bindgen` crate:                        
        - impl<T, A, R> IntoWasmClosure<(dyn Fn(A) -> R + 'static)> for T                                                                                                 
          where <T as FnOnce<(A,)>>::Output == R, T: 'static, T: Fn<(A,)>, A: 'static, A: FromWasmAbi, R: 'static, R: ReturnWasmAbi;                                      
        - impl<T, A, R> IntoWasmClosure<(dyn FnMut(A) -> R + 'static)> for T                                                                                              
          where <T as FnOnce<(A,)>>::Output == R, T: 'static, T: FnMut<(A,)>, A: 'static, A: FromWasmAbi, R: 'static, R: ReturnWasmAbi;                                   
note: required by a bound in Closure::<T>::new
--> C:\Users\Nolan\scoop\persist\rustup.cargo\registry\src\github.com-1ecc6299db9ec823\wasm-bindgen-0.2.81\src\closure.rs:271:12
271 F: IntoWasmClosure + 'static, ^^^^^^^^^^^^^^^^^^ required by this bound in Closure::<T>::new
help: consider specifying the type argument in the function call
87 let closure = Closure::new::(move event: web_sys::Event {
+++++
warning: unused import: ClosureNew
--> src\app.rs:7:26
7 util::{self, window, ClosureNew}, ^^^^^^^^^^

= note: #[warn(unused_imports)] on by default

warning: unused import: ClosureNew
--> src\browser\service\routing.rs:2:18
|
2 | util::{self, ClosureNew},
| ^^^^^^^^^^

warning: unused import: crate::browser::util::ClosureNew
--> src\virtual_dom\event_handler_manager\listener.rs:1:5
|
1 | use crate::browser::util::ClosureNew;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Thanks!

JoelCourtney commented 2 years ago

I was just about to open this myself, thanks! I made an issue in wasm-bindgen here, because I don't think they realized the changes in 0.2.81 would be breaking.

flosse commented 2 years ago

@ndarilek and @JoelCourtney thanks for reporting, I hope we can fix it soon.

flosse commented 2 years ago

fixed in f284711f3fc4a9deebf70c9f0ce4d8ec1daca36f