Skip to content

Commit 991abab

Browse files
authored
Update Rust version for macro tests to 1.51 & enable const generics tests (#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
1 parent 164d554 commit 991abab

File tree

29 files changed

+326
-314
lines changed

29 files changed

+326
-314
lines changed

.github/workflows/pull-request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ jobs:
178178
strategy:
179179
matrix:
180180
toolchain:
181-
- 1.45.0 # MSRV
181+
- 1.51.0 # min version with const generics
182182
- stable
183183
- nightly
184184

CONTRIBUTING.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ Alternatively, you can set the `ECHO_SERVER_URL` environment variable to the URL
6060

6161
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.
6262
These files ensure that macro compilation errors are correct and easy to understand.
63-
These errors can change with each release of the compiler so they should be generated with the MSRV (currently 1.45).
63+
These errors can change with each release of the compiler so they should be generated with the Rust version 1.51
64+
(because some tests make use of const generics which were stabilized in that version).
6465

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

6768
## Linting
6869

examples/nested_list/src/list.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ where
4040
}
4141
}
4242

43-
impl Into<Html> for ListVariant {
44-
fn into(self) -> Html {
45-
match self.props {
43+
impl From<ListVariant> for Html {
44+
fn from(variant: ListVariant) -> Html {
45+
match variant.props {
4646
Variants::Header(props) => {
4747
VComp::new::<ListHeader>(props, NodeRef::default(), None).into()
4848
}

packages/yew-dsl/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ impl<COMP: Component> BoxedVNodeProducer<COMP> {
3737
}
3838
}
3939

40-
impl<COMP: Component> Into<VNode> for BoxedVNodeProducer<COMP> {
41-
fn into(self) -> VNode {
42-
self.build()
40+
impl<COMP: Component> From<BoxedVNodeProducer<COMP>> for VNode {
41+
fn from(value: BoxedVNodeProducer<COMP>) -> VNode {
42+
value.build()
4343
}
4444
}
4545

packages/yew-functional-macro/Makefile.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tasks.test]
22
clear = true
3-
toolchain = "1.45.2"
3+
toolchain = "1.51"
44
command = "cargo"
55
args = ["test"]
66

packages/yew-functional-macro/tests/function_attr/bad-return-type-fail.stderr

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ error[E0308]: mismatched types
88
--> $DIR/bad-return-type-fail.rs:14:5
99
|
1010
13 | fn comp(_props: &Props) -> u32 {
11-
| --- expected `yew::virtual_dom::vnode::VNode` because of return type
11+
| --- expected `VNode` because of return type
1212
14 | 1
13-
| ^ expected enum `yew::virtual_dom::vnode::VNode`, found integer
13+
| ^ expected enum `VNode`, found integer

packages/yew-functional-macro/tests/function_attr/generic-pass.rs

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,20 @@ fn comp1<T1, T2>(_props: &()) -> ::yew::Html {
2020
}
2121
}
2222

23-
// TODO: uncomment when min_const_generics are in stable and Rust version in CI is bumped
24-
// #[::yew_functional::function_component(ConstGenerics)]
25-
// fn const_generics<const N: i32>() -> ::yew::Html {
26-
// ::yew::html! {
27-
// <div>
28-
// { N }
29-
// </div>
30-
// }
31-
// }
23+
#[::yew_functional::function_component(ConstGenerics)]
24+
fn const_generics<const N: i32>() -> ::yew::Html {
25+
::yew::html! {
26+
<div>
27+
{ N }
28+
</div>
29+
}
30+
}
3231

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

37-
// ::yew::html! { <ConstGenerics<10> };
36+
::yew::html! { <ConstGenerics<10> /> };
3837
}
3938

4039
fn main() {}

packages/yew-functional-macro/tests/function_attr/generic-props-fail.stderr

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,44 +15,52 @@ error[E0599]: no method named `build` found for struct `PropsBuilder<PropsBuilde
1515
...
1616
23 | html! { <Comp<Props> /> };
1717
| ^^^^ method not found in `PropsBuilder<PropsBuilderStep_missing_required_prop_a>`
18-
|
19-
= help: items from traits can only be used if the trait is implemented and in scope
20-
= note: the following trait defines an item `build`, perhaps you need to implement it:
21-
candidate #1: `proc_macro::bridge::server::TokenStreamBuilder`
2218

23-
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
19+
error[E0599]: the function or associated item `new` exists for struct `VChild<FunctionComponent<comp<MissingTypeBounds>>>`, but its trait bounds were not satisfied
2420
--> $DIR/generic-props-fail.rs:28:14
2521
|
2622
28 | html! { <Comp<MissingTypeBounds> /> };
27-
| ^^^^ function or associated item not found in `yew::virtual_dom::vcomp::VChild<yew_functional::FunctionComponent<comp<MissingTypeBounds>>>`
23+
| ^^^^ function or associated item cannot be called on `VChild<FunctionComponent<comp<MissingTypeBounds>>>` due to unsatisfied trait bounds
2824
|
2925
::: $WORKSPACE/packages/yew-functional/src/lib.rs
3026
|
3127
| pub struct FunctionComponent<T: FunctionProvider + 'static> {
32-
| ----------------------------------------------------------- doesn't satisfy `_: yew::html::component::Component`
28+
| ----------------------------------------------------------- doesn't satisfy `_: yew::Component`
3329
|
34-
= note: the method `new` exists but the following trait bounds were not satisfied:
35-
`yew_functional::FunctionComponent<comp<MissingTypeBounds>>: yew::html::component::Component`
30+
= note: the following trait bounds were not satisfied:
31+
`FunctionComponent<comp<MissingTypeBounds>>: yew::Component`
3632

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

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

54-
error[E0107]: wrong number of type arguments: expected 1, found 0
50+
error[E0107]: missing generics for type alias `Comp`
5551
--> $DIR/generic-props-fail.rs:31:14
5652
|
5753
31 | html! { <Comp /> };
5854
| ^^^^ expected 1 type argument
55+
|
56+
note: type alias defined here, with 1 type parameter: `P`
57+
--> $DIR/generic-props-fail.rs:9:22
58+
|
59+
9 | #[function_component(Comp)]
60+
| ^^^^
61+
10 | fn comp<P>(_props: &P) -> Html
62+
| -
63+
help: use angle brackets to add missing type argument
64+
|
65+
31 | html! { <Comp<P> /> };
66+
| ^^^

packages/yew-functional-macro/tests/function_attr_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#[allow(dead_code)]
2-
#[rustversion::attr(stable(1.45), test)]
2+
#[rustversion::attr(stable(1.51), test)]
33
fn tests() {
44
let t = trybuild::TestCases::new();
55
t.pass("tests/function_attr/*-pass.rs");

packages/yew-macro/Makefile.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tasks.test]
22
clear = true
3-
toolchain = "1.45.2"
3+
toolchain = "1.51"
44
command = "cargo"
55
args = ["test"]
66

0 commit comments

Comments
 (0)