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

Update Rust version for macro tests to 1.51 & enable const generics tests #1801

Merged
merged 6 commits into from
Mar 30, 2021
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 1 addition & 1 deletion .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,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 @@ -60,9 +60,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 `TRYBUILD=overwrite cargo +1.51 test` in the `yew-macro` directory.
ranile marked this conversation as resolved.
Show resolved Hide resolved

## 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
19 changes: 9 additions & 10 deletions packages/yew-functional-macro/tests/function_attr/generic-pass.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,20 @@ fn comp1<T1, T2>(_props: &()) -> ::yew::Html {
}
}

// TODO: uncomment when min_const_generics are in stable and Rust version in CI is bumped
// #[::yew_functional::function_component(ConstGenerics)]
// fn const_generics<const N: i32>() -> ::yew::Html {
// ::yew::html! {
// <div>
// { N }
// </div>
// }
// }
#[::yew_functional::function_component(ConstGenerics)]
fn const_generics<const N: i32>() -> ::yew::Html {
::yew::html! {
<div>
{ N }
</div>
}
}

fn compile_pass() {
::yew::html! { <Comp<Props> a=10 /> };
::yew::html! { <Comp1<usize, usize> /> };

// ::yew::html! { <ConstGenerics<10> };
::yew::html! { <ConstGenerics<10> /> };
}

fn main() {}
Original file line number Diff line number Diff line change
Expand Up @@ -15,44 +15,52 @@ error[E0599]: no method named `build` found for struct `PropsBuilder<PropsBuilde
...
23 | html! { <Comp<Props> /> };
| ^^^^ method not found in `PropsBuilder<PropsBuilderStep_missing_required_prop_a>`
|
= help: items from traits can only be used if the trait is implemented and in scope
= note: the following trait defines an item `build`, perhaps you need to implement it:
candidate #1: `proc_macro::bridge::server::TokenStreamBuilder`

error[E0599]: no function or associated item named `new` found for struct `yew::virtual_dom::vcomp::VChild<yew_functional::FunctionComponent<comp<MissingTypeBounds>>>` in the current scope
error[E0599]: the function or associated item `new` exists for struct `VChild<FunctionComponent<comp<MissingTypeBounds>>>`, but its trait bounds were not satisfied
--> $DIR/generic-props-fail.rs:28:14
|
28 | html! { <Comp<MissingTypeBounds> /> };
| ^^^^ function or associated item not found in `yew::virtual_dom::vcomp::VChild<yew_functional::FunctionComponent<comp<MissingTypeBounds>>>`
| ^^^^ function or associated item cannot be called on `VChild<FunctionComponent<comp<MissingTypeBounds>>>` due to unsatisfied trait bounds
|
::: $WORKSPACE/packages/yew-functional/src/lib.rs
|
| pub struct FunctionComponent<T: FunctionProvider + 'static> {
| ----------------------------------------------------------- doesn't satisfy `_: yew::html::component::Component`
| ----------------------------------------------------------- doesn't satisfy `_: yew::Component`
|
= note: the method `new` exists but the following trait bounds were not satisfied:
`yew_functional::FunctionComponent<comp<MissingTypeBounds>>: yew::html::component::Component`
= note: the following trait bounds were not satisfied:
`FunctionComponent<comp<MissingTypeBounds>>: yew::Component`

error[E0277]: the trait bound `MissingTypeBounds: yew::html::component::properties::Properties` is not satisfied
error[E0277]: the trait bound `MissingTypeBounds: yew::Properties` is not satisfied
--> $DIR/generic-props-fail.rs:28:14
|
28 | html! { <Comp<MissingTypeBounds> /> };
| ^^^^ the trait `yew::html::component::properties::Properties` is not implemented for `MissingTypeBounds`
| ^^^^ the trait `yew::Properties` is not implemented for `MissingTypeBounds`
|
= note: required because of the requirements on the impl of `yew_functional::FunctionProvider` for `comp<MissingTypeBounds>`
= note: required because of the requirements on the impl of `FunctionProvider` for `comp<MissingTypeBounds>`

error[E0277]: can't compare `MissingTypeBounds` with `MissingTypeBounds`
--> $DIR/generic-props-fail.rs:28:14
|
28 | html! { <Comp<MissingTypeBounds> /> };
| ^^^^ no implementation for `MissingTypeBounds == MissingTypeBounds`
|
= help: the trait `std::cmp::PartialEq` is not implemented for `MissingTypeBounds`
= note: required because of the requirements on the impl of `yew_functional::FunctionProvider` for `comp<MissingTypeBounds>`
= help: the trait `PartialEq` is not implemented for `MissingTypeBounds`
= note: required because of the requirements on the impl of `FunctionProvider` for `comp<MissingTypeBounds>`

error[E0107]: wrong number of type arguments: expected 1, found 0
error[E0107]: missing generics for type alias `Comp`
--> $DIR/generic-props-fail.rs:31:14
|
31 | html! { <Comp /> };
| ^^^^ expected 1 type argument
|
note: type alias defined here, with 1 type parameter: `P`
--> $DIR/generic-props-fail.rs:9:22
|
9 | #[function_component(Comp)]
| ^^^^
10 | fn comp<P>(_props: &P) -> Html
| -
help: use angle brackets to add missing type argument
|
31 | html! { <Comp<P> /> };
| ^^^
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
8 changes: 4 additions & 4 deletions packages/yew-macro/src/props/prop_macro.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ impl Parse for PropValue {
}
}

impl Into<Prop> for PropValue {
fn into(self) -> Prop {
let Self {
impl From<PropValue> for Prop {
fn from(prop_value: PropValue) -> Prop {
let PropValue {
label,
colon_token,
value,
} = self;
} = prop_value;
Prop {
label,
question_mark: None,
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
Loading