Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[web-sys] yew 0.13 fails to compile #996

Closed
Rulliam opened this issue Mar 4, 2020 · 5 comments · Fixed by #997
Closed

[web-sys] yew 0.13 fails to compile #996

Rulliam opened this issue Mar 4, 2020 · 5 comments · Fixed by #997
Labels

Comments

@Rulliam
Copy link

Rulliam commented Mar 4, 2020

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
@Rulliam Rulliam added the bug label Mar 4, 2020
Detegr added a commit to Detegr/yew that referenced this issue Mar 4, 2020
CharacterData needs to be deref'd to make a Node out of it.
Fixes yewstack#996
@captain-yossarian
Copy link
Contributor

I have same error. Please see comment

@Detegr
Copy link
Contributor

Detegr commented Mar 4, 2020

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

@Type1J
Copy link
Contributor

Type1J commented Mar 4, 2020

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).

@jstarry
Copy link
Member

jstarry commented Mar 4, 2020

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?

jstarry pushed a commit that referenced this issue Mar 4, 2020
CharacterData needs to be deref'd to make a Node out of it.
Fixes #996
@jstarry
Copy link
Member

jstarry commented Mar 4, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants