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

Remove Component validation in html! to allow for generic components #1065

Merged
merged 2 commits into from
Apr 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 0 additions & 6 deletions crates/macro/src/html_tree/html_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,6 @@ impl ToTokens for HtmlComponent {
},
};

let validate_comp = quote_spanned! { ty.span()=>
trait __yew_validate_comp: ::yew::html::Component {}
impl __yew_validate_comp for #ty {}
};

let node_ref = if let Some(node_ref) = props.node_ref() {
quote_spanned! { node_ref.span()=> #node_ref }
} else {
Expand All @@ -163,7 +158,6 @@ impl ToTokens for HtmlComponent {
// These validation checks show a nice error message to the user.
// They do not execute at runtime
if false {
#validate_comp
#validate_props
}

Expand Down
16 changes: 14 additions & 2 deletions crates/macro/tests/macro/html-component-fail-unimplemented.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
error[E0599]: no function or associated item named `new` found for struct `yew::virtual_dom::vcomp::VChild<std::string::String>` in the current scope
--> $DIR/html-component-fail-unimplemented.rs:6:5
|
6 | html! { <String /> };
| ^^^^^^^^^^^^^^^^^^^^^ function or associated item not found in `yew::virtual_dom::vcomp::VChild<std::string::String>`
|
= note: the method `new` exists but the following trait bounds were not satisfied:
`std::string::String : yew::html::Component`
= 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[E0277]: the trait bound `std::string::String: yew::html::Component` is not satisfied
--> $DIR/html-component-fail-unimplemented.rs:6:14
--> $DIR/html-component-fail-unimplemented.rs:6:5
|
6 | html! { <String /> };
| ^^^^^^ the trait `yew::html::Component` is not implemented for `std::string::String`
| ^^^^^^^^^^^^^^^^^^^^^ the trait `yew::html::Component` is not implemented for `std::string::String`
|
= note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)