Skip to content

Commit

Permalink
update rust version for macro test to 1.51
Browse files Browse the repository at this point in the history
  • Loading branch information
ranile committed Mar 30, 2021
1 parent cdefd15 commit 0c795b8
Show file tree
Hide file tree
Showing 21 changed files with 280 additions and 267 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ jobs:
strategy:
matrix:
toolchain:
- 1.45.0 # MSRV
- 1.51.0 # min version with const generics
- stable

steps:
Expand Down Expand Up @@ -183,7 +183,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.

## Linting

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
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ 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! {
Expand Down
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
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
41 changes: 26 additions & 15 deletions packages/yew-macro/tests/derive_props/fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ error: cannot find attribute `props` in this scope
|
22 | #[props(default)]
| ^^^^^
|
= note: consider importing one of these items:
yew::props
yew_macro::props

error[E0425]: cannot find value `foo` in this scope
--> $DIR/fail.rs:87:24
Expand Down Expand Up @@ -40,12 +44,8 @@ error[E0599]: no method named `build` found for struct `t3::PropsBuilder<t3::Pro
...
35 | Props::builder().build();
| ^^^^^ method not found in `t3::PropsBuilder<t3::PropsBuilderStep_missing_required_prop_value>`
|
= 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 method named `b` found for struct `t4::PropsBuilder<t4::PropsBuilderStep_missing_required_prop_a>` in the current scope
error[E0599]: no method named `b` found for struct `t4::PropsBuilder<PropsBuilderStep_missing_required_prop_a>` in the current scope
--> $DIR/fail.rs:48:26
|
41 | #[derive(Clone, Properties)]
Expand All @@ -58,10 +58,14 @@ error[E0308]: mismatched types
--> $DIR/fail.rs:67:19
|
67 | #[prop_or(123)]
| ^^^
| |
| expected struct `std::string::String`, found integer
| help: try using a conversion method: `123.to_string()`
| ^^^ expected struct `String`, found integer
|
help: try using a conversion method
|
67 | #[prop_or(123.to_string())]
| ^^^^^^^^^^^^^^^
67 | #[prop_or(123.to_string())]
| ^^^^^^^^^^^^^^^

error[E0618]: expected function, found `{integer}`
--> $DIR/fail.rs:77:24
Expand All @@ -76,15 +80,22 @@ error[E0061]: this function takes 1 argument but 0 arguments were supplied
| ^^^- supplied 0 arguments
| |
| expected 1 argument
...
|
note: function defined here
--> $DIR/fail.rs:101:8
|
101 | fn foo(bar: i32) -> String {
| -------------------------- defined here
| ^^^ --------

error[E0308]: mismatched types
--> $DIR/fail.rs:111:24
|
111 | #[prop_or_else(foo)]
| ^^^
| |
| expected struct `std::string::String`, found `i32`
| help: try using a conversion method: `foo.to_string()`
| ^^^ expected struct `String`, found `i32`
|
help: try using a conversion method
|
111 | #[prop_or_else(foo.to_string())]
| ^^^^^^^^^^^^^^^
111 | #[prop_or_else(foo.to_string())]
| ^^^^^^^^^^^^^^^
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
Loading

0 comments on commit 0c795b8

Please sign in to comment.