seed-rs / seed

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

Closures need types #694

Closed ziidonato closed 2 years ago

ziidonato commented 2 years ago
error[E0283]: type annotations needed for `Closure<T>`
   --> /home/zii/.cargo/registry/src/github.com-1ecc6299db9ec823/seed-0.9.1/src/browser/service/routing.rs:87:19
    |
87  |     let closure = Closure::new(move |event: web_sys::Event| {
    |         -------   ^^^^^^^^^^^^ cannot infer type for type parameter `T`

   --> /home/zii/.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::<F>(move |event: web_sys::Event| {
    |                               +++++
------------------------------------------------
note: required by a bound in `Closure::<T>::new`
   --> /home/zii/.cargo/registry/src/github.com-1ecc6299db9ec823/wasm-bindgen-0.2.81/src/closure.rs:271:12
    |
271 |         F: IntoWasmClosure<T> + 'static,
    |            ^^^^^^^^^^^^^^^^^^ required by this bound in `Closure::<T>::new`

For more information about this error, try `rustc --explain E0283`.
error: could not compile `seed` due to 2 previous errors

I used seed-quickstart for this, and tried updating to the latest version.

Edit: ._. this may have been a user issue, I wasn't getting any errors in the actual project though... I was doing the todo list tutorial and got the error at project-setup. Delete & re-init seems to have solved it though.

j0lol commented 2 years ago

I have this problem too! following the (admittedly quite old) intoduction to rust web applications book

Toasterson commented 2 years ago

Same here. Might be quickstart that is broken but from the error it's the seed crate and not the quickstart. Tried 3 different versions of seed 0.7.0/0.8.0 and 0.9.1.

Error is happening in a fresh clone and CI https://github.com/OpenFlowLabs/expensebills/runs/7081134689?check_suite_focus=true

@MartinKavik this is a blocker right now.

flosse commented 2 years ago

@j0lol and @Toasterson this is a duplicate of #687

Please use

[patch.crates-io]
seed =  { git = "https://github.com/seed-rs/seed" }

until v0.9.2 is released