Skip to content

Commit

Permalink
Improve component trait check
Browse files Browse the repository at this point in the history
  • Loading branch information
jstarry committed Jul 21, 2019
1 parent b98d557 commit 9781884
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
7 changes: 6 additions & 1 deletion crates/macro/src/html_tree/html_component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,12 @@ impl ToTokens for HtmlComponent {
};

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

tokens.extend(quote! {{
Expand Down
2 changes: 0 additions & 2 deletions tests/macro/html-component-fail-unimplemented.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,5 @@ error[E0277]: the trait bound `std::string::String: yew::html::Component` is not
|
6 | html! { <String /> };
| ^^^^^^ the trait `yew::html::Component` is not implemented for `std::string::String`
|
= help: see issue #48214

For more information about this error, try `rustc --explain E0277`.
1 change: 1 addition & 0 deletions tests/macro_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ fn tests() {

t.pass("tests/macro/html-component-pass.rs");
t.compile_fail("tests/macro/html-component-fail.rs");
t.compile_fail("tests/macro/html-component-fail-unimplemented.rs");

t.pass("tests/macro/html-iterable-pass.rs");
t.compile_fail("tests/macro/html-iterable-fail.rs");
Expand Down

0 comments on commit 9781884

Please sign in to comment.