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:
cargo new --lib project[package]
name = "project"
version = "0.1.0"
edition = "2018"
[dependencies]
yew = { version = "0.13", features = ["web_sys"] }
[lib]
crate-type = ["cdylib", "rlib"]
fn main() {
println!("Hello, world!");
}
cargo wasm build or wasm-pack build (it will be the same error with both) 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:
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!
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!