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

New event macros cause extremely confusing error message #251

Closed
aidanhs opened this issue May 24, 2018 · 6 comments
Closed

New event macros cause extremely confusing error message #251

aidanhs opened this issue May 24, 2018 · 6 comments

Comments

@aidanhs
Copy link
Contributor

aidanhs commented May 24, 2018

Description

I'm submitting a bug

When bumping to the latest commit (00e7a97) of yew, I get extremely confusing error messages of the form

   Compiling logobble-dataflow-page v0.1.0 (file:///home/aidanhs/Desktop/rust/logobble/dataflow-page)
error[E0277]: `[closure@src/lib.rs:207:82: 207:110 job_id:_]` doesn't implement `std::fmt::Display`
   --> src/lib.rs:206:57
    |
206 | /                                                         html!{
207 | |                                                             <div><button onclick=move |_| Msg::GetLog(job_id),  disabled={!job.is_destamped},>
208 | |                                                                 { format!("Job {}", job.id) }
209 | |                                                             </button></div>
210 | |                                                         }
    | |_________________________________________________________^ `[closure@src/lib.rs:207:82: 207:110 job_id:_]` cannot be formatted with the default formatter
    |
    = help: the trait `std::fmt::Display` is not implemented for `[closure@src/lib.rs:207:82: 207:110 job_id:_]`
    = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead
    = note: required because of the requirements on the impl of `std::string::ToString` for `[closure@src/lib.rs:207:82: 207:110 job_id:_]`
    = note: required by `yew::macros::add_attribute`
    = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error: aborting due to previous error
For more information about this error, try `rustc --explain E0277`.
error: Could not compile `logobble-dataflow-page`.

It appears this is because #240 now auto-adds the move keyword.

This was clearly done deliberately, so just raising for visibility.

@limira
Copy link
Contributor

limira commented May 24, 2018

I also encountered this today, but I don't think it is a bug, it is just a breaking change. It affects projects using yew 0.3.
I think we should publish 0.4 as soon as possible. This may help new commers, they will use the latest version (0.4) so they will not encounter confusing error like this. How do you think @deniskolodin ?

@therustmonk
Copy link
Member

You are right! This affects 0.3 and it's a breaking-change. Error message looks terrible, but to support old and new styles I have to make macro very large that's why I decided to support a new one.

To update your templates from 0.3 to 0.4 you should change:

html! {
<input value=&self.name, oninput=move |e: InputData| Msg::UpdateEvent(idx, e.value), />
}

with:

html! {
<input value=&self.name, oninput=|e| Msg::UpdateEvent(idx, e.value), />
}

I prefer to derive types automatically where possible (especially in templates). And move modifier is useful, because a closure inside a template can't borrow the environment.

I like the idea to publish this changes soon, because I am in progress to upgrade the framework to actors model and I have a significant progress in this direction. We shouldn't overload 0.4 release with a lot of changes 👌

@vitiral
Copy link
Contributor

vitiral commented Jun 16, 2018

@deniskolodin I really prefer the new style 👍

I think it would be good to include a changelog for such breaking changes in the future though (this breakage is in 0.4) 😄

@therustmonk
Copy link
Member

I think it would be good to include a changelog for such breaking changes in the future though (this breakage is in 0.4)

@vitiral Very good point! I'll put it in the changelog added with #272 👌

@jstarry
Copy link
Member

jstarry commented Nov 28, 2019

This may be resolved by #756

@jstarry
Copy link
Member

jstarry commented Dec 9, 2019

Removed the magical event macro here: #782

@jstarry jstarry closed this as completed Dec 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants