Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 2 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ jobs:
strategy:
matrix:
toolchain:
- 1.49.0 # MSRV
- 1.54.0 # MSRV
- stable

steps:
Expand Down Expand Up @@ -188,7 +188,7 @@ jobs:
strategy:
matrix:
toolchain:
- 1.51.0 # min version with const generics
- 1.54.0 # MSRV
- stable
- nightly

Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ 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 Rust version 1.51
These errors can change with each release of the compiler, so they should be generated with the Rust version 1.54
(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 `cargo make test-overwrite` in the `yew-macro` directory.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<a href="https://docs.rs/yew/"><img alt="API Docs" src="https://img.shields.io/badge/docs.rs-yew-green"/></a>
<a href="https://discord.gg/VQck8X4"><img alt="Discord Chat" src="https://img.shields.io/discord/701068342760570933"/></a>
<a href="https://gitlocalize.com/repo/4999"> <img src="https://gitlocalize.com/repo/4999/whole_project/badge.svg" /> </a>
<a href="https://blog.rust-lang.org/2020/12/31/Rust-1.49.0.html"><img alt="Rustc Version 1.49.0+" src="https://img.shields.io/badge/rustc-1.49%2B-lightgrey.svg"/></a>
<a href="https://blog.rust-lang.org/2020/12/31/Rust-1.54.0.html"><img alt="Rustc Version 1.54.0+" src="https://img.shields.io/badge/rustc-1.54%2B-lightgrey.svg"/></a>
</p>

<h4>
Expand Down
1 change: 1 addition & 0 deletions packages/yew-macro/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license = "MIT OR Apache-2.0"
keywords = ["web", "wasm", "frontend", "webasm", "webassembly"]
categories = ["gui", "web-programming", "wasm"]
description = "A framework for making client-side single-page apps"
rust-version = "1.54.0"

[lib]
proc-macro = true
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.51"
toolchain = ""
command = "cargo"
# test target can be optionally specified like `cargo make test html_macro`,
args = ["test", "${@}"]
Expand Down
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.51), test)]
#[rustversion::attr(stable(1.54), test)]
fn classes_macro() {
let t = trybuild::TestCases::new();
t.pass("tests/classes_macro/*-pass.rs");
Expand Down
33 changes: 18 additions & 15 deletions packages/yew-macro/tests/derive_props/fail.stderr
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
error: unexpected end of input, expected expression
--> $DIR/fail.rs:57:18
--> tests/derive_props/fail.rs:57:18
|
57 | #[prop_or()]
| ^^

error: cannot find attribute `props` in this scope
--> $DIR/fail.rs:22:11
--> tests/derive_props/fail.rs:22:11
|
22 | #[props(default)]
| ^^^^^
Expand All @@ -15,7 +15,7 @@ error: cannot find attribute `props` in this scope
yew_macro::props

error[E0425]: cannot find value `foo` in this scope
--> $DIR/fail.rs:87:24
--> tests/derive_props/fail.rs:87:24
|
87 | #[prop_or_else(foo)]
| ^^^ not found in this scope
Expand All @@ -28,43 +28,46 @@ help: consider importing one of these items
|

error[E0277]: the trait bound `Value: Default` is not satisfied
--> $DIR/fail.rs:9:21
--> tests/derive_props/fail.rs:9:21
|
9 | #[derive(Clone, Properties, PartialEq)]
| ^^^^^^^^^^ the trait `Default` is not implemented for `Value`
|
= note: required by `Option::<T>::unwrap_or_default`
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `Properties` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0369]: binary operation `==` cannot be applied to type `Value`
--> $DIR/fail.rs:13:9
--> tests/derive_props/fail.rs:13:9
|
13 | value: Value,
| ^^^^^^^^^^^^
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `Value`
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0369]: binary operation `!=` cannot be applied to type `Value`
--> $DIR/fail.rs:13:9
--> tests/derive_props/fail.rs:13:9
|
13 | value: Value,
| ^^^^^^^^^^^^
|
= note: an implementation of `std::cmp::PartialEq` might be missing for `Value`
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0599]: no method named `build` found for struct `t3::PropsBuilder<t3::PropsBuilderStep_missing_required_prop_value>` in the current scope
--> $DIR/fail.rs:35:26
--> tests/derive_props/fail.rs:35:26
|
29 | #[derive(Clone, Properties, PartialEq)]
| ---------- method `build` not found for this
...
35 | Props::builder().build();
| ^^^^^ method not found in `t3::PropsBuilder<t3::PropsBuilderStep_missing_required_prop_value>`
|
= note: the method was found for
- `t3::PropsBuilder<t3::PropsBuilderStepPropsBuilder>`

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
--> tests/derive_props/fail.rs:48:26
|
41 | #[derive(Clone, Properties, PartialEq)]
| ---------- method `b` not found for this
Expand All @@ -73,7 +76,7 @@ error[E0599]: no method named `b` found for struct `t4::PropsBuilder<PropsBuilde
| ^ help: there is an associated function with a similar name: `a`

error[E0308]: mismatched types
--> $DIR/fail.rs:67:19
--> tests/derive_props/fail.rs:67:19
|
67 | #[prop_or(123)]
| ^^^ expected struct `String`, found integer
Expand All @@ -86,7 +89,7 @@ help: try using a conversion method
| ^^^^^^^^^^^^^^^

error[E0277]: expected a `FnOnce<()>` closure, found `{integer}`
--> $DIR/fail.rs:77:24
--> tests/derive_props/fail.rs:77:24
|
77 | #[prop_or_else(123)]
| ^^^ expected an `FnOnce<()>` closure, found `{integer}`
Expand All @@ -95,7 +98,7 @@ error[E0277]: expected a `FnOnce<()>` closure, found `{integer}`
= note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }`

error[E0593]: function is expected to take 0 arguments, but it takes 1 argument
--> $DIR/fail.rs:97:24
--> tests/derive_props/fail.rs:97:24
|
97 | #[prop_or_else(foo)]
| ^^^ expected function that takes 0 arguments
Expand All @@ -104,7 +107,7 @@ error[E0593]: function is expected to take 0 arguments, but it takes 1 argument
| -------------------------- takes 1 argument

error[E0271]: type mismatch resolving `<fn() -> i32 {t10::foo} as FnOnce<()>>::Output == String`
--> $DIR/fail.rs:111:24
--> tests/derive_props/fail.rs:111:24
|
111 | #[prop_or_else(foo)]
| ^^^ expected struct `String`, found `i32`
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.51), test)]
#[rustversion::attr(stable(1.54), test)]
fn derive_props() {
let t = trybuild::TestCases::new();
t.pass("tests/derive_props/pass.rs");
Expand Down
2 changes: 1 addition & 1 deletion packages/yew-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.51), test)]
#[rustversion::attr(stable(1.54), test)]
fn tests() {
let t = trybuild::TestCases::new();
t.pass("tests/function_component_attr/*-pass.rs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ error[E0277]: the trait bound `u32: IntoHtmlResult` is not satisfied
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `IntoHtmlResult` is not implemented for `u32`
|
= note: required by `into_html_result`
= note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the attribute macro `function_component` (in Nightly builds, run with -Z macro-backtrace for more info)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ error[E0599]: no method named `build` found for struct `PropsBuilder<PropsBuilde
...
22 | html! { <Comp<Props> /> };
| ^^^^ method not found in `PropsBuilder<PropsBuilderStep_missing_required_prop_a>`
|
= note: the method was found for
- `PropsBuilder<PropsBuilderStepPropsBuilder>`

error[E0277]: the trait bound `FunctionComponent<CompFunctionProvider<MissingTypeBounds>>: BaseComponent` is not satisfied
--> tests/function_component_attr/generic-props-fail.rs:27:14
Expand Down Expand Up @@ -50,22 +53,27 @@ error[E0277]: the trait bound `MissingTypeBounds: yew::Properties` is not satisf
| pub struct FunctionComponent<T: FunctionProvider + 'static> {
| ---------------- required by this bound in `FunctionComponent`
|
= note: required because of the requirements on the impl of `FunctionProvider` for `CompFunctionProvider<MissingTypeBounds>`
note: required because of the requirements on the impl of `FunctionProvider` for `CompFunctionProvider<MissingTypeBounds>`
--> tests/function_component_attr/generic-props-fail.rs:8:1
|
8 | #[function_component(Comp)]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
= note: this error originates in the attribute macro `function_component` (in Nightly builds, run with -Z macro-backtrace for more info)

error[E0107]: missing generics for type alias `Comp`
--> tests/function_component_attr/generic-props-fail.rs:30:14
|
30 | html! { <Comp /> };
| ^^^^ expected 1 type argument
| ^^^^ expected 1 generic argument
|
note: type alias defined here, with 1 type parameter: `P`
note: type alias defined here, with 1 generic parameter: `P`
--> tests/function_component_attr/generic-props-fail.rs:8:22
|
8 | #[function_component(Comp)]
| ^^^^
9 | fn comp<P>(_props: &P) -> Html
| -
help: use angle brackets to add missing type argument
help: add missing generic argument
|
30 | html! { <Comp<P> /> };
| ^^^
| ^^^^^^^
19 changes: 14 additions & 5 deletions packages/yew-macro/tests/html_macro/component-fail.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -196,10 +196,10 @@ error: `int` can only be specified once but is given here again
| ^^^

error: `ref` can only be specified once
--> tests/html_macro/component-fail.rs:81:26
--> tests/html_macro/component-fail.rs:81:35
|
81 | html! { <Child int=1 ref={()} ref={()} /> };
| ^^^
| ^^^

error: this closing tag has no corresponding opening tag
--> tests/html_macro/component-fail.rs:84:13
Expand Down Expand Up @@ -303,7 +303,7 @@ error[E0609]: no field `r#type` on type `ChildProperties`
|
= note: available fields are: `string`, `int`

error[E0599]: no method named `r#type` found for struct `ChildPropertiesBuilder<ChildPropertiesBuilderStep_missing_required_prop_int>` in the current scope
error[E0599]: no method named `r#type` found for struct `ChildPropertiesBuilder` in the current scope
--> tests/html_macro/component-fail.rs:71:20
|
4 | #[derive(Clone, Properties, PartialEq)]
Expand All @@ -320,7 +320,7 @@ error[E0609]: no field `unknown` on type `ChildProperties`
|
= note: available fields are: `string`, `int`

error[E0599]: no method named `unknown` found for struct `ChildPropertiesBuilder<ChildPropertiesBuilderStep_missing_required_prop_int>` in the current scope
error[E0599]: no method named `unknown` found for struct `ChildPropertiesBuilder` in the current scope
--> tests/html_macro/component-fail.rs:74:20
|
4 | #[derive(Clone, Properties, PartialEq)]
Expand Down Expand Up @@ -381,6 +381,9 @@ error[E0599]: no method named `string` found for struct `ChildPropertiesBuilder<
...
83 | html! { <Child string="abc" /> };
| ^^^^^^ method not found in `ChildPropertiesBuilder<ChildPropertiesBuilderStep_missing_required_prop_int>`
|
= note: the method was found for
- `ChildPropertiesBuilder<ChildPropertiesBuilderStepPropsBuilder>`

error[E0609]: no field `children` on type `ChildProperties`
--> tests/html_macro/component-fail.rs:87:14
Expand All @@ -390,7 +393,7 @@ error[E0609]: no field `children` on type `ChildProperties`
|
= note: available fields are: `string`, `int`

error[E0599]: no method named `children` found for struct `ChildPropertiesBuilder<ChildPropertiesBuilderStep_missing_required_prop_int>` in the current scope
error[E0599]: no method named `children` found for struct `ChildPropertiesBuilder` in the current scope
--> tests/html_macro/component-fail.rs:87:14
|
4 | #[derive(Clone, Properties, PartialEq)]
Expand All @@ -415,6 +418,9 @@ error[E0599]: no method named `build` found for struct `ChildContainerProperties
...
99 | html! { <ChildContainer /> };
| ^^^^^^^^^^^^^^ method not found in `ChildContainerPropertiesBuilder<ChildContainerPropertiesBuilderStep_missing_required_prop_children>`
|
= note: the method was found for
- `ChildContainerPropertiesBuilder<ChildContainerPropertiesBuilderStepPropsBuilder>`

error[E0599]: no method named `build` found for struct `ChildContainerPropertiesBuilder<ChildContainerPropertiesBuilderStep_missing_required_prop_children>` in the current scope
--> tests/html_macro/component-fail.rs:100:14
Expand All @@ -424,6 +430,9 @@ error[E0599]: no method named `build` found for struct `ChildContainerProperties
...
100 | html! { <ChildContainer></ChildContainer> };
| ^^^^^^^^^^^^^^ method not found in `ChildContainerPropertiesBuilder<ChildContainerPropertiesBuilderStep_missing_required_prop_children>`
|
= note: the method was found for
- `ChildContainerPropertiesBuilder<ChildContainerPropertiesBuilderStepPropsBuilder>`

error[E0277]: the trait bound `VChild<Child>: From<yew::virtual_dom::VText>` is not satisfied
--> tests/html_macro/component-fail.rs:101:31
Expand Down
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, html_nested};

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

Expand Down
20 changes: 10 additions & 10 deletions packages/yew-macro/tests/props_macro/props-fail.stderr
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
error: special props cannot be specified in the `props!` macro
--> $DIR/props-fail.rs:9:25
--> tests/props_macro/props-fail.rs:9:25
|
9 | yew::props!(Props { ref: NodeRef::default(), key: "key" });
| ^^^

error: special props cannot be specified in the `props!` macro
--> $DIR/props-fail.rs:9:50
--> tests/props_macro/props-fail.rs:9:50
|
9 | yew::props!(Props { ref: NodeRef::default(), key: "key" });
| ^^^

error: expected ident
--> $DIR/props-fail.rs:13:31
--> tests/props_macro/props-fail.rs:13:31
|
13 | yew::props!(Props { a: 1, ..props });
| ^^

error[E0425]: cannot find value `does_not_exist` in this scope
--> $DIR/props-fail.rs:15:25
--> tests/props_macro/props-fail.rs:15:25
|
15 | yew::props!(Props { does_not_exist });
| ^^^^^^^^^^^^^^ not found in this scope

error[E0609]: no field `fail` on type `Props`
--> $DIR/props-fail.rs:10:31
--> tests/props_macro/props-fail.rs:10:31
|
10 | yew::props!(Props { a: 5, fail: 10 });
| ^^^^ unknown field
|
= note: available fields are: `a`

error[E0599]: no method named `fail` found for struct `PropsBuilder<PropsBuilderStepPropsBuilder>` in the current scope
--> $DIR/props-fail.rs:10:31
error[E0599]: no method named `fail` found for struct `PropsBuilder` in the current scope
--> tests/props_macro/props-fail.rs:10:31
|
3 | #[derive(Clone, Properties, PartialEq)]
| ---------- method `fail` not found for this
Expand All @@ -40,15 +40,15 @@ error[E0599]: no method named `fail` found for struct `PropsBuilder<PropsBuilder
| ^^^^ method not found in `PropsBuilder<PropsBuilderStepPropsBuilder>`

error[E0609]: no field `does_not_exist` on type `Props`
--> $DIR/props-fail.rs:15:25
--> tests/props_macro/props-fail.rs:15:25
|
15 | yew::props!(Props { does_not_exist });
| ^^^^^^^^^^^^^^ unknown field
|
= note: available fields are: `a`

error[E0599]: no method named `does_not_exist` found for struct `PropsBuilder<PropsBuilderStep_missing_required_prop_a>` in the current scope
--> $DIR/props-fail.rs:15:25
error[E0599]: no method named `does_not_exist` found for struct `PropsBuilder` in the current scope
--> tests/props_macro/props-fail.rs:15:25
|
3 | #[derive(Clone, Properties, PartialEq)]
| ---------- method `does_not_exist` not found for this
Expand Down
4 changes: 2 additions & 2 deletions packages/yew-macro/tests/props_macro/resolve-prop-fail.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error[E0277]: can't compare `Props` with `Props`
--> $DIR/resolve-prop-fail.rs:3:17
--> tests/props_macro/resolve-prop-fail.rs:3:17
|
3 | #[derive(Clone, Properties)]
| ^^^^^^^^^^ no implementation for `Props == Props`
Expand All @@ -10,4 +10,4 @@ error[E0277]: can't compare `Props` with `Props`
| --------- required by this bound in `yew::Properties`
|
= help: the trait `PartialEq` is not implemented for `Props`
= note: this error originates in a derive macro (in Nightly builds, run with -Z macro-backtrace for more info)
= note: this error originates in the derive macro `Properties` (in Nightly builds, run with -Z macro-backtrace for more info)
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.51), test)]
#[rustversion::attr(stable(1.54), test)]
fn props_macro() {
let t = trybuild::TestCases::new();
t.pass("tests/props_macro/*-pass.rs");
Expand Down
Loading