Yew: [web-sys] yew 0.13 fails to compile

Created on 4 Mar 2020  路  5Comments  路  Source: yewstack/yew

Problem

I want to update my project from std_web to web_sys.
When trying to build an empty (or not) project with the new feature web_sys, yew 0.13 does not compile.

Steps To Reproduce
Steps to reproduce the behavior:

  1. cargo new --lib project
  2. Cargo.toml
[package]
name = "project"
version = "0.1.0"
edition = "2018"

[dependencies]
yew = { version = "0.13", features = ["web_sys"] }

[lib]
crate-type = ["cdylib", "rlib"]
  1. src/lib.rs
fn main() {
    println!("Hello, world!");
}
  1. Run cargo wasm build or wasm-pack build (it will be the same error with both)
  2. See error
   Compiling yew v0.13.0
error[E0308]: mismatched types
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/yew-0.13.0/src/virtual_dom/vtext.rs:113:9
    |
60  |       ) -> Option<Node> {
    |            ------------ expected `std::option::Option<web_sys::features::gen_Node::Node>` because of return type
...
113 | /         self.reference.as_ref().map(|t| {
114 | |             let node = cfg_match! {
115 | |                 feature = "std_web" => t.as_node(),
116 | |                 feature = "web_sys" => t.deref(),
117 | |             };
118 | |             node.to_owned()
119 | |         })
    | |__________^ expected struct `web_sys::features::gen_Node::Node`, found struct `web_sys::features::gen_CharacterData::CharacterData`
    |
    = note: expected enum `std::option::Option<web_sys::features::gen_Node::Node>`
               found enum `std::option::Option<web_sys::features::gen_CharacterData::CharacterData>`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0308`.
error: could not compile `yew`.

To learn more, run the command again with --verbose.
Failed to run cargo. Exit code was: 101

Expected behavior
I was expecting yew to build, but maybe am I doing something wrong ?

Environment:

  • Yew v0.13
  • Rust v1.41.1
  • Target wasm32-unknown-unknown
  • web-sys v0.3.36
  • OS: ubuntu
bug

Most helpful comment

Yeah v0.3.36 was the issue, I just pushed yew v0.13.1 with @Detegr's fix. Thanks for the reports everyone!

All 5 comments

I have same error. Please see comment

I have the same problem as well. I tried to fix it but it looks like my naive fix won't pass tests.

Same here. For reference: compiling https://github.com/test_web/yew-wasm-pack-template yields the same error as above, but before it even gets to the current project (The error seems to be from cargo compiling yew itself).

Are all of you on web-sys v0.3.36? I think the latest release might have broken things. Can you try on v0.3.35?

Yeah v0.3.36 was the issue, I just pushed yew v0.13.1 with @Detegr's fix. Thanks for the reports everyone!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

IngwiePhoenix picture IngwiePhoenix  路  4Comments

sackery picture sackery  路  3Comments

kellytk picture kellytk  路  3Comments

FrontMage picture FrontMage  路  4Comments

alun picture alun  路  4Comments