Skip to content

Commit

Permalink
Update Rust version for macro tests to 1.51 & enable const generics t…
Browse files Browse the repository at this point in the history
…ests (yewstack#1801)

* update rust version for macro test to 1.51

* enable const generic tests

* run integration tests using MSRV

* am blind

* clippy, fmt

* apply suggestion
  • Loading branch information
ranile authored and cecton committed Apr 25, 2021
1 parent af93a08 commit 9728825
Show file tree
Hide file tree
Showing 20 changed files with 127 additions and 120 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ jobs:
strategy:
matrix:
toolchain:
- 1.45.0 # MSRV
- 1.51.0 # min version with const generics
- stable
- nightly

Expand Down
5 changes: 3 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,10 @@ Alternatively, you can set the `ECHO_SERVER_URL` environment variable to the URL

When adding or updating tests, please make sure to update the appropriate `stderr` file, which you can find [here](https://github.com/yewstack/yew/tree/master/packages/yew-macro/tests/macro) for the `html!` macro.
These files ensure that macro compilation errors are correct and easy to understand.
These errors can change with each release of the compiler so they should be generated with the MSRV (currently 1.45).
These errors can change with each release of the compiler so they should be generated with the Rust version 1.51
(because some tests make use of const generics which were stabilized in that version).

To update or generate a new `stderr` file you can run `TRYBUILD=overwrite cargo +1.45.2 test` in the `yew-macro` directory.
To update or generate a new `stderr` file you can run `cargo make test-overwrite` in the `yew-macro` directory.

## Linting

Expand Down
6 changes: 3 additions & 3 deletions examples/nested_list/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ where
}
}

impl Into<Html> for ListVariant {
fn into(self) -> Html {
match self.props {
impl From<ListVariant> for Html {
fn from(variant: ListVariant) -> Html {
match variant.props {
Variants::Header(props) => {
VComp::new::<ListHeader>(props, NodeRef::default(), None).into()
}
Expand Down
6 changes: 3 additions & 3 deletions packages/yew-dsl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ impl<COMP: Component> BoxedVNodeProducer<COMP> {
}
}

impl<COMP: Component> Into<VNode> for BoxedVNodeProducer<COMP> {
fn into(self) -> VNode {
self.build()
impl<COMP: Component> From<BoxedVNodeProducer<COMP>> for VNode {
fn from(value: BoxedVNodeProducer<COMP>) -> VNode {
value.build()
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/yew-functional-macro/Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tasks.test]
clear = true
toolchain = "1.45.2"
toolchain = "1.51"
command = "cargo"
args = ["test"]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ error[E0308]: mismatched types
--> $DIR/bad-return-type-fail.rs:14:5
|
13 | fn comp(_props: &Props) -> u32 {
| --- expected `yew::virtual_dom::vnode::VNode` because of return type
| --- expected `VNode` because of return type
14 | 1
| ^ expected enum `yew::virtual_dom::vnode::VNode`, found integer
| ^ expected enum `VNode`, found integer
2 changes: 1 addition & 1 deletion packages/yew-functional-macro/tests/function_attr_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[allow(dead_code)]
#[rustversion::attr(stable(1.45), test)]
#[rustversion::attr(stable(1.51), test)]
fn tests() {
let t = trybuild::TestCases::new();
t.pass("tests/function_attr/*-pass.rs");
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-macro/Makefile.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tasks.test]
clear = true
toolchain = "1.45.2"
toolchain = "1.51"
command = "cargo"
args = ["test"]

Expand Down
99 changes: 51 additions & 48 deletions packages/yew-macro/tests/classes_macro/classes-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -10,92 +10,95 @@ error: string literals must not contain more than one class (hint: use `"two", "
18 | classes!("one", "two three", "four");
| ^^^^^^^^^^^

error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From<{integer}>` is not satisfied
error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
--> $DIR/classes-fail.rs:4:14
|
4 | classes!(42);
| ^^ the trait `std::convert::From<{integer}>` is not implemented for `yew::html::classes::Classes`
| ^^ the trait `From<{integer}>` is not implemented for `Classes`
|
= help: the following implementations were found:
<yew::html::classes::Classes as std::convert::From<&'static str>>
<yew::html::classes::Classes as std::convert::From<&[T]>>
<yew::html::classes::Classes as std::convert::From<&std::option::Option<T>>>
<yew::html::classes::Classes as std::convert::From<&std::string::String>>
<Classes as From<&'static str>>
<Classes as From<&Option<T>>>
<Classes as From<&String>>
<Classes as From<&[T]>>
and 4 others
= note: required because of the requirements on the impl of `std::convert::Into<yew::html::classes::Classes>` for `{integer}`
= note: required because of the requirements on the impl of `Into<Classes>` for `{integer}`

error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From<{float}>` is not satisfied
error[E0277]: the trait bound `Classes: From<{float}>` is not satisfied
--> $DIR/classes-fail.rs:5:14
|
5 | classes!(42.0);
| ^^^^ the trait `std::convert::From<{float}>` is not implemented for `yew::html::classes::Classes`
| ^^^^ the trait `From<{float}>` is not implemented for `Classes`
|
= help: the following implementations were found:
<yew::html::classes::Classes as std::convert::From<&'static str>>
<yew::html::classes::Classes as std::convert::From<&[T]>>
<yew::html::classes::Classes as std::convert::From<&std::option::Option<T>>>
<yew::html::classes::Classes as std::convert::From<&std::string::String>>
<Classes as From<&'static str>>
<Classes as From<&Option<T>>>
<Classes as From<&String>>
<Classes as From<&[T]>>
and 4 others
= note: required because of the requirements on the impl of `std::convert::Into<yew::html::classes::Classes>` for `{float}`
= note: required because of the requirements on the impl of `Into<Classes>` for `{float}`

error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From<{integer}>` is not satisfied
error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
--> $DIR/classes-fail.rs:9:14
|
9 | classes!(vec![42]);
| ^^^ the trait `std::convert::From<{integer}>` is not implemented for `yew::html::classes::Classes`
| ^^^ the trait `From<{integer}>` is not implemented for `Classes`
|
= help: the following implementations were found:
<yew::html::classes::Classes as std::convert::From<&'static str>>
<yew::html::classes::Classes as std::convert::From<&[T]>>
<yew::html::classes::Classes as std::convert::From<&std::option::Option<T>>>
<yew::html::classes::Classes as std::convert::From<&std::string::String>>
<Classes as From<&'static str>>
<Classes as From<&Option<T>>>
<Classes as From<&String>>
<Classes as From<&[T]>>
and 4 others
= note: required because of the requirements on the impl of `std::convert::Into<yew::html::classes::Classes>` for `{integer}`
= note: required because of the requirements on the impl of `std::convert::From<std::vec::Vec<{integer}>>` for `yew::html::classes::Classes`
= note: required because of the requirements on the impl of `std::convert::Into<yew::html::classes::Classes>` for `std::vec::Vec<{integer}>`
= note: required because of the requirements on the impl of `Into<Classes>` for `{integer}`
= note: required because of the requirements on the impl of `From<std::vec::Vec<{integer}>>` for `Classes`
= note: 1 redundant requirements hidden
= note: required because of the requirements on the impl of `Into<Classes>` for `std::vec::Vec<{integer}>`

error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From<{integer}>` is not satisfied
error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
--> $DIR/classes-fail.rs:13:14
|
13 | classes!(some);
| ^^^^ the trait `std::convert::From<{integer}>` is not implemented for `yew::html::classes::Classes`
| ^^^^ the trait `From<{integer}>` is not implemented for `Classes`
|
= help: the following implementations were found:
<yew::html::classes::Classes as std::convert::From<&'static str>>
<yew::html::classes::Classes as std::convert::From<&[T]>>
<yew::html::classes::Classes as std::convert::From<&std::option::Option<T>>>
<yew::html::classes::Classes as std::convert::From<&std::string::String>>
<Classes as From<&'static str>>
<Classes as From<&Option<T>>>
<Classes as From<&String>>
<Classes as From<&[T]>>
and 4 others
= note: required because of the requirements on the impl of `std::convert::Into<yew::html::classes::Classes>` for `{integer}`
= note: required because of the requirements on the impl of `std::convert::From<std::option::Option<{integer}>>` for `yew::html::classes::Classes`
= note: required because of the requirements on the impl of `std::convert::Into<yew::html::classes::Classes>` for `std::option::Option<{integer}>`
= note: required because of the requirements on the impl of `Into<Classes>` for `{integer}`
= note: required because of the requirements on the impl of `From<Option<{integer}>>` for `Classes`
= note: 1 redundant requirements hidden
= note: required because of the requirements on the impl of `Into<Classes>` for `Option<{integer}>`

error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From<u32>` is not satisfied
error[E0277]: the trait bound `Classes: From<u32>` is not satisfied
--> $DIR/classes-fail.rs:14:14
|
14 | classes!(none);
| ^^^^ the trait `std::convert::From<u32>` is not implemented for `yew::html::classes::Classes`
| ^^^^ the trait `From<u32>` is not implemented for `Classes`
|
= help: the following implementations were found:
<yew::html::classes::Classes as std::convert::From<&'static str>>
<yew::html::classes::Classes as std::convert::From<&[T]>>
<yew::html::classes::Classes as std::convert::From<&std::option::Option<T>>>
<yew::html::classes::Classes as std::convert::From<&std::string::String>>
<Classes as From<&'static str>>
<Classes as From<&Option<T>>>
<Classes as From<&String>>
<Classes as From<&[T]>>
and 4 others
= note: required because of the requirements on the impl of `std::convert::Into<yew::html::classes::Classes>` for `u32`
= note: required because of the requirements on the impl of `std::convert::From<std::option::Option<u32>>` for `yew::html::classes::Classes`
= note: required because of the requirements on the impl of `std::convert::Into<yew::html::classes::Classes>` for `std::option::Option<u32>`
= note: required because of the requirements on the impl of `Into<Classes>` for `u32`
= note: required because of the requirements on the impl of `From<Option<u32>>` for `Classes`
= note: 1 redundant requirements hidden
= note: required because of the requirements on the impl of `Into<Classes>` for `Option<u32>`

error[E0277]: the trait bound `yew::html::classes::Classes: std::convert::From<{integer}>` is not satisfied
error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
--> $DIR/classes-fail.rs:16:21
|
16 | classes!("one", 42);
| ^^ the trait `std::convert::From<{integer}>` is not implemented for `yew::html::classes::Classes`
| ^^ the trait `From<{integer}>` is not implemented for `Classes`
|
= help: the following implementations were found:
<yew::html::classes::Classes as std::convert::From<&'static str>>
<yew::html::classes::Classes as std::convert::From<&[T]>>
<yew::html::classes::Classes as std::convert::From<&std::option::Option<T>>>
<yew::html::classes::Classes as std::convert::From<&std::string::String>>
<Classes as From<&'static str>>
<Classes as From<&Option<T>>>
<Classes as From<&String>>
<Classes as From<&[T]>>
and 4 others
= note: required because of the requirements on the impl of `std::convert::Into<yew::html::classes::Classes>` for `{integer}`
= note: required because of the requirements on the impl of `Into<Classes>` for `{integer}`
2 changes: 1 addition & 1 deletion packages/yew-macro/tests/classes_macro_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[allow(dead_code)]
#[rustversion::attr(stable(1.45), test)]
#[rustversion::attr(stable(1.51), test)]
fn classes_macro() {
let t = trybuild::TestCases::new();
t.pass("tests/classes_macro/*-pass.rs");
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-macro/tests/derive_props_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[allow(dead_code)]
#[rustversion::attr(stable(1.45), test)]
#[rustversion::attr(stable(1.51), test)]
fn derive_props() {
let t = trybuild::TestCases::new();
t.pass("tests/derive_props/pass.rs");
Expand Down
32 changes: 16 additions & 16 deletions packages/yew-macro/tests/html_macro/html-block-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ error[E0277]: `()` doesn't implement `std::fmt::Display`
|
= help: the trait `std::fmt::Display` is not implemented for `()`
= 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 `()`
= note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::virtual_dom::vnode::VNode`
= note: required because of the requirements on the impl of `std::convert::Into<yew::virtual_dom::vnode::VNode>` for `()`
= note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::utils::NodeSeq<(), yew::virtual_dom::vnode::VNode>`
= note: required because of the requirements on the impl of `std::convert::Into<yew::utils::NodeSeq<(), yew::virtual_dom::vnode::VNode>>` for `()`
= note: required by `std::convert::Into::into`
= note: required because of the requirements on the impl of `ToString` for `()`
= note: required because of the requirements on the impl of `From<()>` for `VNode`
= note: required because of the requirements on the impl of `Into<VNode>` for `()`
= note: 2 redundant requirements hidden
= note: required because of the requirements on the impl of `Into<NodeSeq<(), VNode>>` for `()`
= note: required by `into`

error[E0277]: `()` doesn't implement `std::fmt::Display`
--> $DIR/html-block-fail.rs:12:16
Expand All @@ -21,12 +21,12 @@ error[E0277]: `()` doesn't implement `std::fmt::Display`
|
= help: the trait `std::fmt::Display` is not implemented for `()`
= 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 `()`
= note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::virtual_dom::vnode::VNode`
= note: required because of the requirements on the impl of `std::convert::Into<yew::virtual_dom::vnode::VNode>` for `()`
= note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::utils::NodeSeq<(), yew::virtual_dom::vnode::VNode>`
= note: required because of the requirements on the impl of `std::convert::Into<yew::utils::NodeSeq<(), yew::virtual_dom::vnode::VNode>>` for `()`
= note: required by `std::convert::Into::into`
= note: required because of the requirements on the impl of `ToString` for `()`
= note: required because of the requirements on the impl of `From<()>` for `VNode`
= note: required because of the requirements on the impl of `Into<VNode>` for `()`
= note: 2 redundant requirements hidden
= note: required because of the requirements on the impl of `Into<NodeSeq<(), VNode>>` for `()`
= note: required by `into`

error[E0277]: `()` doesn't implement `std::fmt::Display`
--> $DIR/html-block-fail.rs:15:17
Expand All @@ -37,10 +37,10 @@ error[E0277]: `()` doesn't implement `std::fmt::Display`
::: $WORKSPACE/packages/yew/src/utils.rs
|
| T: Into<R>,
| ------- required by this bound in `yew::utils::into_node_iter`
| ------- required by this bound in `into_node_iter`
|
= help: the trait `std::fmt::Display` is not implemented for `()`
= 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 `()`
= note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::virtual_dom::vnode::VNode`
= note: required because of the requirements on the impl of `std::convert::Into<yew::virtual_dom::vnode::VNode>` for `()`
= note: required because of the requirements on the impl of `ToString` for `()`
= note: required because of the requirements on the impl of `From<()>` for `VNode`
= note: required because of the requirements on the impl of `Into<VNode>` for `()`
12 changes: 6 additions & 6 deletions packages/yew-macro/tests/html_macro/html-node-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,9 @@ error[E0277]: `()` doesn't implement `std::fmt::Display`
|
= help: the trait `std::fmt::Display` is not implemented for `()`
= 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 `()`
= note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::virtual_dom::vnode::VNode`
= note: required by `std::convert::From::from`
= note: required because of the requirements on the impl of `ToString` for `()`
= note: required because of the requirements on the impl of `From<()>` for `VNode`
= note: required by `from`

error[E0277]: `()` doesn't implement `std::fmt::Display`
--> $DIR/html-node-fail.rs:17:9
Expand All @@ -60,6 +60,6 @@ error[E0277]: `()` doesn't implement `std::fmt::Display`
|
= help: the trait `std::fmt::Display` is not implemented for `()`
= 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 `()`
= note: required because of the requirements on the impl of `std::convert::From<()>` for `yew::virtual_dom::vnode::VNode`
= note: required by `std::convert::From::from`
= note: required because of the requirements on the impl of `ToString` for `()`
= note: required because of the requirements on the impl of `From<()>` for `VNode`
= note: required by `from`
2 changes: 1 addition & 1 deletion packages/yew-macro/tests/html_macro_test.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use yew::html;

#[allow(dead_code)]
#[rustversion::attr(stable(1.45), test)]
#[rustversion::attr(stable(1.51), test)]
fn html_macro() {
let t = trybuild::TestCases::new();

Expand Down
16 changes: 10 additions & 6 deletions packages/yew-macro/tests/props_macro/resolve-prop-fail.stderr
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
error[E0277]: the trait bound `std::vec::Vec<_>: yew::html::component::properties::Properties` is not satisfied
error[E0277]: the trait bound `std::vec::Vec<_>: yew::Properties` is not satisfied
--> $DIR/resolve-prop-fail.rs:38:17
|
38 | yew::props!(Vec<_> {});
| ^^^ the trait `yew::html::component::properties::Properties` is not implemented for `std::vec::Vec<_>`
| ^^^ the trait `yew::Properties` is not implemented for `std::vec::Vec<_>`
|
= note: required by `builder`

error[E0277]: the trait bound `MyComp: yew::html::component::properties::Properties` is not satisfied
error[E0277]: the trait bound `MyComp: yew::Properties` is not satisfied
--> $DIR/resolve-prop-fail.rs:39:17
|
39 | yew::props!(MyComp {});
| ^^^^^^ the trait `yew::html::component::properties::Properties` is not implemented for `MyComp`
| ^^^^^^ the trait `yew::Properties` is not implemented for `MyComp`
|
= note: required by `builder`

error[E0277]: the trait bound `MyNotAComponent: yew::html::component::Component` is not satisfied
error[E0277]: the trait bound `MyNotAComponent: yew::Component` is not satisfied
--> $DIR/resolve-prop-fail.rs:40:17
|
40 | yew::props!(MyNotAComponent::Properties {});
| ^^^^^^^^^^^^^^^ the trait `yew::html::component::Component` is not implemented for `MyNotAComponent`
| ^^^^^^^^^^^^^^^ the trait `yew::Component` is not implemented for `MyNotAComponent`
2 changes: 1 addition & 1 deletion packages/yew-macro/tests/props_macro_test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#[allow(dead_code)]
#[rustversion::attr(stable(1.45), test)]
#[rustversion::attr(stable(1.51), test)]
fn props_macro() {
let t = trybuild::TestCases::new();
t.pass("tests/props_macro/*-pass.rs");
Expand Down
Loading

0 comments on commit 9728825

Please sign in to comment.