Skip to content

Commit d84e9e6

Browse files
committed
concise diagnostics for missing props
1 parent 4d08a03 commit d84e9e6

File tree

50 files changed

+338
-166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+338
-166
lines changed

.github/workflows/main-checks.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ jobs:
6969
fail-fast: false
7070
matrix:
7171
toolchain:
72-
- 1.76.0
72+
- 1.78.0
7373
- stable
7474

7575
steps:
@@ -120,7 +120,7 @@ jobs:
120120
fail-fast: false
121121
matrix:
122122
toolchain:
123-
- 1.76.0
123+
- 1.78.0
124124
- stable
125125
- nightly
126126

packages/yew-agent-macro/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "yew-agent-macro"
33
version = "0.2.0"
44
edition = "2021"
5-
rust-version = "1.76.0"
5+
rust-version = "1.78.0"
66
authors = ["Kaede Hoshikawa <futursolo@icloud.com>"]
77
repository = "https://github.com/yewstack/yew"
88
homepage = "https://yew.rs"

packages/yew-agent/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ edition = "2021"
99
readme = "../../README.md"
1010
description = "Agents for Yew"
1111
license = "MIT OR Apache-2.0"
12-
rust-version = "1.76.0"
12+
rust-version = "1.78.0"
1313

1414
[dependencies]
1515
yew = { version = "0.21.0", path = "../yew" }

packages/yew-macro/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ license = "MIT OR Apache-2.0"
1010
keywords = ["web", "wasm", "frontend", "webasm", "webassembly"]
1111
categories = ["gui", "web-programming", "wasm"]
1212
description = "A framework for making client-side single-page apps"
13-
rust-version = "1.76.0"
13+
rust-version = "1.78.0"
1414

1515
[lib]
1616
proc-macro = true

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.76.0"
3+
toolchain = "1.78.0"
44
command = "cargo"
55
# test target can be optionally specified like `cargo make test html_macro`,
66
args = ["test", "${@}"]

packages/yew-macro/src/derive_props/builder.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ impl PropsBuilder<'_> {
127127
quote! {
128128
#[automatically_derived]
129129
#( #extra_attrs )*
130+
#[diagnostic::do_not_recommend]
130131
impl #builder_impl_generics #builder_name<#generic_args> #builder_where_clause {
131132
#( #prop_fns )*
132133
}
@@ -142,11 +143,13 @@ impl PropsBuilder<'_> {
142143
#vis struct #check_all_props_name<How>(::std::marker::PhantomData<How>);
143144

144145
#[automatically_derived]
146+
#[diagnostic::do_not_recommend]
145147
impl<B, P, How> ::yew::html::HasProp<P, &dyn ::yew::html::HasProp<P, How>>
146148
for #check_all_props_name<B>
147149
where B: ::yew::html::HasProp<P, How> {}
148150

149151
#[automatically_derived]
152+
#[diagnostic::do_not_recommend]
150153
impl #check_impl_generics ::yew::html::HasAllProps<
151154
#props_name #ty_generics ,
152155
( #( #check_args , )* ),

packages/yew-macro/src/derive_props/field.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,12 @@ impl PropFieldCheck<'_> {
245245
#vis struct #check_struct<How>(::std::marker::PhantomData<How>);
246246

247247
#[automatically_derived]
248+
#[diagnostic::do_not_recommend]
248249
impl<B> ::yew::html::HasProp< #prop_name_mod :: #prop_check_name, #check_struct<B>>
249250
for #check_struct<B> {}
251+
250252
#[automatically_derived]
253+
#[diagnostic::do_not_recommend]
251254
impl<B, P, How> ::yew::html::HasProp<P, &dyn ::yew::html::HasProp<P, How>>
252255
for #check_struct<B>
253256
where B: ::yew::html::HasProp<P, How> {}

packages/yew-macro/tests/classes_macro/classes-fail.stderr

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
1414
--> tests/classes_macro/classes-fail.rs:4:14
1515
|
1616
4 | classes!(42);
17-
| ^^ the trait `From<{integer}>` is not implemented for `Classes`
17+
| ^^ the trait `From<{integer}>` is not implemented for `Classes`, which is required by `{integer}: Into<Classes>`
1818
|
1919
= help: the following other types implement trait `From<T>`:
20-
<Classes as From<Cow<'static, str>>>
2120
<Classes as From<implicit_clone::unsync::string::IString>>
21+
<Classes as From<Cow<'static, str>>>
2222
<Classes as From<Vec<T>>>
2323
<Classes as From<String>>
2424
<Classes as From<Option<T>>>
@@ -37,11 +37,11 @@ error[E0277]: the trait bound `Classes: From<{float}>` is not satisfied
3737
--> tests/classes_macro/classes-fail.rs:5:14
3838
|
3939
5 | classes!(42.0);
40-
| ^^^^ the trait `From<{float}>` is not implemented for `Classes`
40+
| ^^^^ the trait `From<{float}>` is not implemented for `Classes`, which is required by `{float}: Into<Classes>`
4141
|
4242
= help: the following other types implement trait `From<T>`:
43-
<Classes as From<Cow<'static, str>>>
4443
<Classes as From<implicit_clone::unsync::string::IString>>
44+
<Classes as From<Cow<'static, str>>>
4545
<Classes as From<Vec<T>>>
4646
<Classes as From<String>>
4747
<Classes as From<Option<T>>>
@@ -62,12 +62,12 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
6262
9 | classes!(vec![42]);
6363
| ---^^^^^
6464
| |
65-
| the trait `From<{integer}>` is not implemented for `Classes`
65+
| the trait `From<{integer}>` is not implemented for `Classes`, which is required by `Vec<{integer}>: Into<Classes>`
6666
| required by a bound introduced by this call
6767
|
6868
= help: the following other types implement trait `From<T>`:
69-
<Classes as From<Cow<'static, str>>>
7069
<Classes as From<implicit_clone::unsync::string::IString>>
70+
<Classes as From<Cow<'static, str>>>
7171
<Classes as From<Vec<T>>>
7272
<Classes as From<String>>
7373
<Classes as From<Option<T>>>
@@ -89,11 +89,11 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
8989
--> tests/classes_macro/classes-fail.rs:13:14
9090
|
9191
13 | classes!(some);
92-
| ^^^^ the trait `From<{integer}>` is not implemented for `Classes`
92+
| ^^^^ the trait `From<{integer}>` is not implemented for `Classes`, which is required by `Option<{integer}>: Into<Classes>`
9393
|
9494
= help: the following other types implement trait `From<T>`:
95-
<Classes as From<Cow<'static, str>>>
9695
<Classes as From<implicit_clone::unsync::string::IString>>
96+
<Classes as From<Cow<'static, str>>>
9797
<Classes as From<Vec<T>>>
9898
<Classes as From<String>>
9999
<Classes as From<Option<T>>>
@@ -115,11 +115,11 @@ error[E0277]: the trait bound `Classes: From<u32>` is not satisfied
115115
--> tests/classes_macro/classes-fail.rs:14:14
116116
|
117117
14 | classes!(none);
118-
| ^^^^ the trait `From<u32>` is not implemented for `Classes`
118+
| ^^^^ the trait `From<u32>` is not implemented for `Classes`, which is required by `Option<u32>: Into<Classes>`
119119
|
120120
= help: the following other types implement trait `From<T>`:
121-
<Classes as From<Cow<'static, str>>>
122121
<Classes as From<implicit_clone::unsync::string::IString>>
122+
<Classes as From<Cow<'static, str>>>
123123
<Classes as From<Vec<T>>>
124124
<Classes as From<String>>
125125
<Classes as From<Option<T>>>
@@ -141,11 +141,11 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied
141141
--> tests/classes_macro/classes-fail.rs:16:21
142142
|
143143
16 | classes!("one", 42);
144-
| ^^ the trait `From<{integer}>` is not implemented for `Classes`
144+
| ^^ the trait `From<{integer}>` is not implemented for `Classes`, which is required by `{integer}: Into<Classes>`
145145
|
146146
= help: the following other types implement trait `From<T>`:
147-
<Classes as From<Cow<'static, str>>>
148147
<Classes as From<implicit_clone::unsync::string::IString>>
148+
<Classes as From<Cow<'static, str>>>
149149
<Classes as From<Vec<T>>>
150150
<Classes as From<String>>
151151
<Classes as From<Option<T>>>

packages/yew-macro/tests/classes_macro_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.76), test)]
2+
#[rustversion::attr(stable(1.78), test)]
33
fn classes_macro() {
44
let t = trybuild::TestCases::new();
55
t.pass("tests/classes_macro/*-pass.rs");

packages/yew-macro/tests/derive_props/fail.stderr

Lines changed: 18 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,14 @@ help: consider annotating `Value` with `#[derive(PartialEq)]`
6161
9 | struct Value;
6262
|
6363

64-
error[E0277]: the trait bound `AssertAllProps: HasProp<t3::_Props::value, _>` is not satisfied
64+
error[E0277]: not all required properties have been provided
6565
--> tests/derive_props/fail.rs:35:24
6666
|
6767
35 | ::yew::props!{ Props { } };
68-
| ^^^^^ the trait `HasProp<t3::_Props::value, _>` is not implemented for `AssertAllProps`
69-
|
70-
= help: the following other types implement trait `HasProp<P, How>`:
71-
<t1::CheckPropsAll<B> as HasProp<P, &dyn HasProp<P, How>>>
72-
<t2::HasPropsvalue<B> as HasProp<t2::_Props::value, t2::HasPropsvalue<B>>>
73-
<t2::HasPropsvalue<B> as HasProp<P, &dyn HasProp<P, How>>>
74-
<t2::CheckPropsAll<B> as HasProp<P, &dyn HasProp<P, How>>>
75-
<t3::HasPropsvalue<B> as HasProp<t3::_Props::value, t3::HasPropsvalue<B>>>
76-
<t3::HasPropsvalue<B> as HasProp<P, &dyn HasProp<P, How>>>
77-
<t3::CheckPropsAll<B> as HasProp<P, &dyn HasProp<P, How>>>
78-
<t4::HasPropsvalue<B> as HasProp<t4::_Props::value, t4::HasPropsvalue<B>>>
79-
and $N others
68+
| ^^^^^ missing required properties for this component
69+
|
70+
= help: the trait `HasProp<t3::_Props::value, _>` is not implemented for `AssertAllProps`, which is required by `AssertAllProps: AllPropsFor<t3::PropsBuilder, _>`
71+
= note: make sure all required properties are set before building the component
8072
note: required for `t3::CheckPropsAll<AssertAllProps>` to implement `HasAllProps<t3::Props, (_,)>`
8173
--> tests/derive_props/fail.rs:29:21
8274
|
@@ -93,22 +85,14 @@ note: required by a bound in `html::component::properties::__macro::PreBuild::<T
9385
| ^^^^^^^^^^^^^^^^^^^ required by this bound in `PreBuild::<Token, B>::build`
9486
= note: this error originates in the derive macro `Properties` (in Nightly builds, run with -Z macro-backtrace for more info)
9587

96-
error[E0277]: the trait bound `AssertAllProps: HasProp<t4::_Props::value, _>` is not satisfied
88+
error[E0277]: not all required properties have been provided
9789
--> tests/derive_props/fail.rs:47:24
9890
|
9991
47 | ::yew::props!{ Props { } };
100-
| ^^^^^ the trait `HasProp<t4::_Props::value, _>` is not implemented for `AssertAllProps`
101-
|
102-
= help: the following other types implement trait `HasProp<P, How>`:
103-
<t1::CheckPropsAll<B> as HasProp<P, &dyn HasProp<P, How>>>
104-
<t2::HasPropsvalue<B> as HasProp<t2::_Props::value, t2::HasPropsvalue<B>>>
105-
<t2::HasPropsvalue<B> as HasProp<P, &dyn HasProp<P, How>>>
106-
<t2::CheckPropsAll<B> as HasProp<P, &dyn HasProp<P, How>>>
107-
<t3::HasPropsvalue<B> as HasProp<t3::_Props::value, t3::HasPropsvalue<B>>>
108-
<t3::HasPropsvalue<B> as HasProp<P, &dyn HasProp<P, How>>>
109-
<t3::CheckPropsAll<B> as HasProp<P, &dyn HasProp<P, How>>>
110-
<t4::HasPropsvalue<B> as HasProp<t4::_Props::value, t4::HasPropsvalue<B>>>
111-
and $N others
92+
| ^^^^^ missing required properties for this component
93+
|
94+
= help: the trait `HasProp<t4::_Props::value, _>` is not implemented for `AssertAllProps`, which is required by `AssertAllProps: AllPropsFor<t4::PropsBuilder, _>`
95+
= note: make sure all required properties are set before building the component
11296
note: required for `t4::CheckPropsAll<AssertAllProps>` to implement `HasAllProps<t4::Props, (_,)>`
11397
--> tests/derive_props/fail.rs:41:21
11498
|
@@ -168,3 +152,11 @@ error[E0271]: expected `foo` to be a fn item that returns `String`, but it retur
168152
|
169153
note: required by a bound in `Option::<T>::unwrap_or_else`
170154
--> $RUST/core/src/option.rs
155+
156+
warning: unused variable: `bar`
157+
--> tests/derive_props/fail.rs:100:12
158+
|
159+
100 | fn foo(bar: i32) -> String {
160+
| ^^^ help: if this is intentional, prefix it with an underscore: `_bar`
161+
|
162+
= note: `#[warn(unused_variables)]` on by default

0 commit comments

Comments
 (0)