yewstack / yew

Rust / Wasm framework for creating reliable and efficient web applications
https://yew.rs
Apache License 2.0
30.23k stars 1.41k forks source link

implicit_clone does not play nice with indexmap 2.26 #3655

Closed diliop closed 2 months ago

diliop commented 2 months ago

Problem If yew's indexmap dependency is upgraded to 2.2.6 the following error can be seen when building:

error[E0277]: the trait bound `implicit_clone::unsync::IMap<_, _>: From<IndexMap<K, V>>` is not satisfied
   --> packages/yew/src/html/conversion/into_prop_value.rs:277:9
    |
277 |         IMap::from(self)
    |         ^^^^ the trait `From<IndexMap<K, V>>` is not implemented for `implicit_clone::unsync::IMap<_, _>`
    |
    = help: the following other types implement trait `From<T>`:
              <implicit_clone::unsync::IMap<K, V> as From<indexmap::map::IndexMap<K, V>>>
              <implicit_clone::unsync::IMap<K, V> as From<std::rc::Rc<indexmap::map::IndexMap<K, V>>>>
              <implicit_clone::unsync::IMap<K, V> as From<&'static [(K, V)]>>
              <implicit_clone::unsync::IMap<K, V> as From<&implicit_clone::unsync::IMap<K, V>>>

I see that From<IndexMap<K, V>> is implemented here so I'm definitely misunderstanding something. Any pointers appreciated!

Steps To Reproduce

  1. Update packages/yew/Cargo.toml to:
    diff --git a/packages/yew/Cargo.toml b/packages/yew/Cargo.toml
    index 27c6c545..4dc03941 100644
    --- a/packages/yew/Cargo.toml
    +++ b/packages/yew/Cargo.toml
    @@ -19,7 +19,7 @@ rust-version = "1.64.0"
    [dependencies]
    console_error_panic_hook = "0.1"
    gloo = "0.10"
    -indexmap = { version = "2", features = ["std"] }
    +indexmap = { version = "2.2.6", features = ["std"] }
    js-sys = "0.3"
    slab = "0.4"
    wasm-bindgen = "0.2"
  2. Run cargo build

Expected behavior cargo build is successful

Environment:

Questionnaire

deftsp commented 2 months ago

I get that problem from time to time, executing a cargo update will fix it. No idea why.

ranile commented 2 months ago

I get that problem from time to time, executing a cargo update will fix it. No idea why.

If cargo update fixes it then the reason for this error is that implicit_clone's dependency in the lockfile isn't updated when you modify the Cargo.toml. You have to tell cargo to update indexmap everywhere

deftsp commented 2 months ago

Yes, I have a crate that depends on indexmap, it is shared by both frontend and backend. Doing a cargo update for frontend after cargo update for backend will prevent the problem.

diliop commented 2 months ago

Thanks for the suggestions, that fixed it!