From b4d083ef8fe04706293f66ebdfbbd0bad5a6fd60 Mon Sep 17 00:00:00 2001 From: Siyuan Yan <44753941+Madoshakalaka@users.noreply.github.com> Date: Wed, 9 Jul 2025 22:29:57 +0900 Subject: [PATCH] concise diagnostics for missing props (#3873) --- .github/workflows/main-checks.yml | 4 +- examples/wasi_ssr_module/src/main.rs | 2 +- examples/web_worker_fib/src/lib.rs | 2 +- packages/yew-agent-macro/Cargo.toml | 2 +- packages/yew-agent/Cargo.toml | 2 +- packages/yew-macro/Cargo.toml | 2 +- packages/yew-macro/Makefile.toml | 2 +- .../yew-macro/src/derive_props/builder.rs | 2 + packages/yew-macro/src/derive_props/field.rs | 3 + .../tests/classes_macro/classes-fail.stderr | 24 +++--- .../yew-macro/tests/classes_macro_test.rs | 2 +- .../yew-macro/tests/derive_props/fail.stderr | 38 ++++----- packages/yew-macro/tests/derive_props/pass.rs | 1 - packages/yew-macro/tests/derive_props_test.rs | 2 +- .../yew-macro/tests/function_attr_test.rs | 2 +- .../function_component_attr/generic-pass.rs | 1 - .../generic-props-fail.stderr | 20 ++--- .../hook_location-pass.rs | 1 - .../no-name-default-pass.rs | 1 - .../with-defaulted-type-param-pass.rs | 1 - .../with-props-pass.rs | 2 - packages/yew-macro/tests/hook_attr_test.rs | 2 +- packages/yew-macro/tests/hook_macro_test.rs | 2 +- .../tests/html_macro/block-fail.stderr | 12 +-- .../html_macro/component-any-children-pass.rs | 2 - .../tests/html_macro/component-fail.stderr | 60 +++++--------- .../tests/html_macro/component-pass.rs | 2 - .../component-unimplemented-fail.stderr | 7 +- .../tests/html_macro/element-fail.stderr | 21 ++--- .../tests/html_macro/iterable-fail.stderr | 35 ++++++-- .../missing-props-diagnostics-fail.rs | 35 ++++++++ .../missing-props-diagnostics-fail.stderr | 83 +++++++++++++++++++ .../tests/html_macro/node-fail.stderr | 11 +-- packages/yew-macro/tests/html_macro_test.rs | 2 +- .../yew-macro/tests/props_macro/props-pass.rs | 1 - .../props_macro/resolve-prop-fail.stderr | 51 +++++++++++- .../tests/props_macro/resolve-prop-pass.rs | 1 - packages/yew-macro/tests/props_macro_test.rs | 2 +- packages/yew-router-macro/Cargo.toml | 2 +- packages/yew-router-macro/Makefile.toml | 2 +- .../tests/routable_derive_test.rs | 2 +- packages/yew-router/Cargo.toml | 2 +- packages/yew/Cargo.toml | 2 +- packages/yew/src/html/component/properties.rs | 12 +++ .../build-examples/src/bin/update-wasm-opt.rs | 20 ++--- tools/build-examples/src/lib.rs | 5 +- tools/build-examples/src/main.rs | 6 +- website/docs/getting-started/introduction.mdx | 2 +- .../current/getting-started/introduction.mdx | 2 +- .../getting-started/introduction.mdx | 2 +- .../current/getting-started/introduction.mdx | 2 +- .../getting-started/introduction.mdx | 2 +- .../current/getting-started/introduction.mdx | 2 +- .../getting-started/introduction.mdx | 2 +- .../getting-started/introduction.mdx | 2 +- 55 files changed, 331 insertions(+), 183 deletions(-) create mode 100644 packages/yew-macro/tests/html_macro/missing-props-diagnostics-fail.rs create mode 100644 packages/yew-macro/tests/html_macro/missing-props-diagnostics-fail.stderr diff --git a/.github/workflows/main-checks.yml b/.github/workflows/main-checks.yml index 608b0a9c3..dea07999d 100644 --- a/.github/workflows/main-checks.yml +++ b/.github/workflows/main-checks.yml @@ -69,7 +69,7 @@ jobs: fail-fast: false matrix: toolchain: - - 1.76.0 + - 1.78.0 - stable steps: @@ -120,7 +120,7 @@ jobs: fail-fast: false matrix: toolchain: - - 1.76.0 + - 1.78.0 - stable - nightly diff --git a/examples/wasi_ssr_module/src/main.rs b/examples/wasi_ssr_module/src/main.rs index e6ba2e316..0637f7497 100644 --- a/examples/wasi_ssr_module/src/main.rs +++ b/examples/wasi_ssr_module/src/main.rs @@ -54,7 +54,7 @@ pub async fn render() -> Result { #[tokio::main(flavor = "current_thread")] async fn main() -> Result<()> { let ret = render().await?; - println!("{}", ret); + println!("{ret}"); Ok(()) } diff --git a/examples/web_worker_fib/src/lib.rs b/examples/web_worker_fib/src/lib.rs index 5d072bf3e..10a1f69fd 100644 --- a/examples/web_worker_fib/src/lib.rs +++ b/examples/web_worker_fib/src/lib.rs @@ -29,7 +29,7 @@ fn Main() -> Html { // start the worker let output_value = fib_agent.run(input_value).await; - output.set(format!("Fibonacci value: {}", output_value)); + output.set(format!("Fibonacci value: {output_value}")); }); } }; diff --git a/packages/yew-agent-macro/Cargo.toml b/packages/yew-agent-macro/Cargo.toml index 383213dcd..ba525a378 100644 --- a/packages/yew-agent-macro/Cargo.toml +++ b/packages/yew-agent-macro/Cargo.toml @@ -2,7 +2,7 @@ name = "yew-agent-macro" version = "0.2.0" edition = "2021" -rust-version = "1.76.0" +rust-version = "1.78.0" authors = ["Kaede Hoshikawa "] repository = "https://github.com/yewstack/yew" homepage = "https://yew.rs" diff --git a/packages/yew-agent/Cargo.toml b/packages/yew-agent/Cargo.toml index 0f8b9adb5..f83c59229 100644 --- a/packages/yew-agent/Cargo.toml +++ b/packages/yew-agent/Cargo.toml @@ -9,7 +9,7 @@ edition = "2021" readme = "../../README.md" description = "Agents for Yew" license = "MIT OR Apache-2.0" -rust-version = "1.76.0" +rust-version = "1.78.0" [dependencies] yew = { version = "0.21.0", path = "../yew" } diff --git a/packages/yew-macro/Cargo.toml b/packages/yew-macro/Cargo.toml index 556de28a0..66d60663f 100644 --- a/packages/yew-macro/Cargo.toml +++ b/packages/yew-macro/Cargo.toml @@ -10,7 +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.76.0" +rust-version = "1.78.0" [lib] proc-macro = true diff --git a/packages/yew-macro/Makefile.toml b/packages/yew-macro/Makefile.toml index f1a5a6ad1..f8f0a7ee4 100644 --- a/packages/yew-macro/Makefile.toml +++ b/packages/yew-macro/Makefile.toml @@ -1,6 +1,6 @@ [tasks.test] clear = true -toolchain = "1.76.0" +toolchain = "1.78.0" command = "cargo" # test target can be optionally specified like `cargo make test html_macro`, args = ["test", "${@}"] diff --git a/packages/yew-macro/src/derive_props/builder.rs b/packages/yew-macro/src/derive_props/builder.rs index b6adb82fc..f5696fe60 100644 --- a/packages/yew-macro/src/derive_props/builder.rs +++ b/packages/yew-macro/src/derive_props/builder.rs @@ -142,11 +142,13 @@ impl PropsBuilder<'_> { #vis struct #check_all_props_name(::std::marker::PhantomData); #[automatically_derived] + #[diagnostic::do_not_recommend] impl ::yew::html::HasProp> for #check_all_props_name where B: ::yew::html::HasProp {} #[automatically_derived] + #[diagnostic::do_not_recommend] impl #check_impl_generics ::yew::html::HasAllProps< #props_name #ty_generics , ( #( #check_args , )* ), diff --git a/packages/yew-macro/src/derive_props/field.rs b/packages/yew-macro/src/derive_props/field.rs index 9654a6e25..09ee98090 100644 --- a/packages/yew-macro/src/derive_props/field.rs +++ b/packages/yew-macro/src/derive_props/field.rs @@ -245,9 +245,12 @@ impl PropFieldCheck<'_> { #vis struct #check_struct(::std::marker::PhantomData); #[automatically_derived] + #[diagnostic::do_not_recommend] impl ::yew::html::HasProp< #prop_name_mod :: #prop_check_name, #check_struct> for #check_struct {} + #[automatically_derived] + #[diagnostic::do_not_recommend] impl ::yew::html::HasProp> for #check_struct where B: ::yew::html::HasProp {} diff --git a/packages/yew-macro/tests/classes_macro/classes-fail.stderr b/packages/yew-macro/tests/classes_macro/classes-fail.stderr index 9987bf14a..3a97a82d5 100644 --- a/packages/yew-macro/tests/classes_macro/classes-fail.stderr +++ b/packages/yew-macro/tests/classes_macro/classes-fail.stderr @@ -14,11 +14,11 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied --> tests/classes_macro/classes-fail.rs:4:14 | 4 | classes!(42); - | ^^ the trait `From<{integer}>` is not implemented for `Classes` + | ^^ the trait `From<{integer}>` is not implemented for `Classes`, which is required by `{integer}: Into` | = help: the following other types implement trait `From`: - >> > + >> >> > >> @@ -37,11 +37,11 @@ error[E0277]: the trait bound `Classes: From<{float}>` is not satisfied --> tests/classes_macro/classes-fail.rs:5:14 | 5 | classes!(42.0); - | ^^^^ the trait `From<{float}>` is not implemented for `Classes` + | ^^^^ the trait `From<{float}>` is not implemented for `Classes`, which is required by `{float}: Into` | = help: the following other types implement trait `From`: - >> > + >> >> > >> @@ -62,12 +62,12 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied 9 | classes!(vec![42]); | ---^^^^^ | | - | the trait `From<{integer}>` is not implemented for `Classes` + | the trait `From<{integer}>` is not implemented for `Classes`, which is required by `Vec<{integer}>: Into` | required by a bound introduced by this call | = help: the following other types implement trait `From`: - >> > + >> >> > >> @@ -89,11 +89,11 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied --> tests/classes_macro/classes-fail.rs:13:14 | 13 | classes!(some); - | ^^^^ the trait `From<{integer}>` is not implemented for `Classes` + | ^^^^ the trait `From<{integer}>` is not implemented for `Classes`, which is required by `Option<{integer}>: Into` | = help: the following other types implement trait `From`: - >> > + >> >> > >> @@ -115,11 +115,11 @@ error[E0277]: the trait bound `Classes: From` is not satisfied --> tests/classes_macro/classes-fail.rs:14:14 | 14 | classes!(none); - | ^^^^ the trait `From` is not implemented for `Classes` + | ^^^^ the trait `From` is not implemented for `Classes`, which is required by `Option: Into` | = help: the following other types implement trait `From`: - >> > + >> >> > >> @@ -141,11 +141,11 @@ error[E0277]: the trait bound `Classes: From<{integer}>` is not satisfied --> tests/classes_macro/classes-fail.rs:16:21 | 16 | classes!("one", 42); - | ^^ the trait `From<{integer}>` is not implemented for `Classes` + | ^^ the trait `From<{integer}>` is not implemented for `Classes`, which is required by `{integer}: Into` | = help: the following other types implement trait `From`: - >> > + >> >> > >> diff --git a/packages/yew-macro/tests/classes_macro_test.rs b/packages/yew-macro/tests/classes_macro_test.rs index fdf00df08..5d6b7df69 100644 --- a/packages/yew-macro/tests/classes_macro_test.rs +++ b/packages/yew-macro/tests/classes_macro_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.76), test)] +#[rustversion::attr(stable(1.78), test)] fn classes_macro() { let t = trybuild::TestCases::new(); t.pass("tests/classes_macro/*-pass.rs"); diff --git a/packages/yew-macro/tests/derive_props/fail.stderr b/packages/yew-macro/tests/derive_props/fail.stderr index b03963506..53f4f3ce7 100644 --- a/packages/yew-macro/tests/derive_props/fail.stderr +++ b/packages/yew-macro/tests/derive_props/fail.stderr @@ -61,22 +61,13 @@ help: consider annotating `Value` with `#[derive(PartialEq)]` 9 | struct Value; | -error[E0277]: the trait bound `AssertAllProps: HasProp` is not satisfied +error[E0277]: not all required properties have been provided --> tests/derive_props/fail.rs:35:24 | 35 | ::yew::props!{ Props { } }; - | ^^^^^ the trait `HasProp` is not implemented for `AssertAllProps` + | ^^^^^ missing required properties for this component | - = help: the following other types implement trait `HasProp`: - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - and $N others + = help: the trait `HasProp` is not implemented for `AssertAllProps`, which is required by `AssertAllProps: AllPropsFor` note: required for `t3::CheckPropsAll` to implement `HasAllProps` --> tests/derive_props/fail.rs:29:21 | @@ -93,22 +84,13 @@ note: required by a bound in `html::component::properties::__macro::PreBuild::::build` = note: this error originates in the derive macro `Properties` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `AssertAllProps: HasProp` is not satisfied +error[E0277]: not all required properties have been provided --> tests/derive_props/fail.rs:47:24 | 47 | ::yew::props!{ Props { } }; - | ^^^^^ the trait `HasProp` is not implemented for `AssertAllProps` + | ^^^^^ missing required properties for this component | - = help: the following other types implement trait `HasProp`: - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - and $N others + = help: the trait `HasProp` is not implemented for `AssertAllProps`, which is required by `AssertAllProps: AllPropsFor` note: required for `t4::CheckPropsAll` to implement `HasAllProps` --> tests/derive_props/fail.rs:41:21 | @@ -168,3 +150,11 @@ error[E0271]: expected `foo` to be a fn item that returns `String`, but it retur | note: required by a bound in `Option::::unwrap_or_else` --> $RUST/core/src/option.rs + +warning: unused variable: `bar` + --> tests/derive_props/fail.rs:100:12 + | +100 | fn foo(bar: i32) -> String { + | ^^^ help: if this is intentional, prefix it with an underscore: `_bar` + | + = note: `#[warn(unused_variables)]` on by default diff --git a/packages/yew-macro/tests/derive_props/pass.rs b/packages/yew-macro/tests/derive_props/pass.rs index 39086f805..a224ee603 100644 --- a/packages/yew-macro/tests/derive_props/pass.rs +++ b/packages/yew-macro/tests/derive_props/pass.rs @@ -1,4 +1,3 @@ -#![no_implicit_prelude] #![recursion_limit = "128"] // Shadow primitives diff --git a/packages/yew-macro/tests/derive_props_test.rs b/packages/yew-macro/tests/derive_props_test.rs index 674d9a763..e4a974ada 100644 --- a/packages/yew-macro/tests/derive_props_test.rs +++ b/packages/yew-macro/tests/derive_props_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.76), test)] +#[rustversion::attr(stable(1.78), test)] fn derive_props() { let t = trybuild::TestCases::new(); t.pass("tests/derive_props/pass.rs"); diff --git a/packages/yew-macro/tests/function_attr_test.rs b/packages/yew-macro/tests/function_attr_test.rs index ec02d2630..c32d8b5c0 100644 --- a/packages/yew-macro/tests/function_attr_test.rs +++ b/packages/yew-macro/tests/function_attr_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.76), test)] +#[rustversion::attr(stable(1.78), test)] fn tests() { let t = trybuild::TestCases::new(); t.pass("tests/function_component_attr/*-pass.rs"); diff --git a/packages/yew-macro/tests/function_component_attr/generic-pass.rs b/packages/yew-macro/tests/function_component_attr/generic-pass.rs index 40653add2..f515e202c 100644 --- a/packages/yew-macro/tests/function_component_attr/generic-pass.rs +++ b/packages/yew-macro/tests/function_component_attr/generic-pass.rs @@ -1,4 +1,3 @@ -#![no_implicit_prelude] // Shadow primitives #[allow(non_camel_case_types)] diff --git a/packages/yew-macro/tests/function_component_attr/generic-props-fail.stderr b/packages/yew-macro/tests/function_component_attr/generic-props-fail.stderr index df2912f89..0174b6a89 100644 --- a/packages/yew-macro/tests/function_component_attr/generic-props-fail.stderr +++ b/packages/yew-macro/tests/function_component_attr/generic-props-fail.stderr @@ -9,22 +9,13 @@ help: you might be missing a type parameter 20 | fn compile_fail() { | +++++++++ -error[E0277]: the trait bound `AssertAllProps: HasProp` is not satisfied +error[E0277]: not all required properties have been provided --> tests/function_component_attr/generic-props-fail.rs:22:14 | 22 | html! { /> }; - | ^^^^ the trait `HasProp` is not implemented for `AssertAllProps` + | ^^^^ missing required properties for this component | - = help: the following other types implement trait `HasProp`: - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - and $N others + = help: the trait `HasProp` is not implemented for `AssertAllProps`, which is required by `AssertAllProps: AllPropsFor` note: required for `CheckPropsAll` to implement `HasAllProps` --> tests/function_component_attr/generic-props-fail.rs:3:17 | @@ -80,6 +71,11 @@ error[E0599]: the function or associated item `new` exists for struct `VChild /> }; | ^^^^ function or associated item cannot be called on `VChild>` due to unsatisfied trait bounds | +note: if you're trying to build a new `VChild>`, consider using `VChild::::new` which returns `VChild<_>` + --> $WORKSPACE/packages/yew/src/virtual_dom/vcomp.rs + | + | pub fn new(props: COMP::Properties, key: Option) -> Self { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the following trait bounds were not satisfied: `Comp: yew::BaseComponent` note: the trait `yew::BaseComponent` must be implemented diff --git a/packages/yew-macro/tests/function_component_attr/hook_location-pass.rs b/packages/yew-macro/tests/function_component_attr/hook_location-pass.rs index b2bcbe111..ce6d04427 100644 --- a/packages/yew-macro/tests/function_component_attr/hook_location-pass.rs +++ b/packages/yew-macro/tests/function_component_attr/hook_location-pass.rs @@ -1,4 +1,3 @@ -#![no_implicit_prelude] #[derive( ::std::prelude::rust_2021::Debug, diff --git a/packages/yew-macro/tests/function_component_attr/no-name-default-pass.rs b/packages/yew-macro/tests/function_component_attr/no-name-default-pass.rs index d9cffd61d..79a0dec12 100644 --- a/packages/yew-macro/tests/function_component_attr/no-name-default-pass.rs +++ b/packages/yew-macro/tests/function_component_attr/no-name-default-pass.rs @@ -1,4 +1,3 @@ -#![no_implicit_prelude] #[derive(::yew::prelude::Properties, ::std::prelude::rust_2021::PartialEq,)] struct Props { diff --git a/packages/yew-macro/tests/function_component_attr/with-defaulted-type-param-pass.rs b/packages/yew-macro/tests/function_component_attr/with-defaulted-type-param-pass.rs index c3c27da1f..a96463cb2 100644 --- a/packages/yew-macro/tests/function_component_attr/with-defaulted-type-param-pass.rs +++ b/packages/yew-macro/tests/function_component_attr/with-defaulted-type-param-pass.rs @@ -1,4 +1,3 @@ -#![no_implicit_prelude] #[derive(::yew::prelude::Properties, ::std::fmt::Debug)] pub struct CompProps { diff --git a/packages/yew-macro/tests/function_component_attr/with-props-pass.rs b/packages/yew-macro/tests/function_component_attr/with-props-pass.rs index 4ce8843d2..be8d2e4e7 100644 --- a/packages/yew-macro/tests/function_component_attr/with-props-pass.rs +++ b/packages/yew-macro/tests/function_component_attr/with-props-pass.rs @@ -1,5 +1,3 @@ -#![no_implicit_prelude] - // Shadow primitives #[allow(non_camel_case_types)] pub struct bool; diff --git a/packages/yew-macro/tests/hook_attr_test.rs b/packages/yew-macro/tests/hook_attr_test.rs index 6298193ca..4724cf82e 100644 --- a/packages/yew-macro/tests/hook_attr_test.rs +++ b/packages/yew-macro/tests/hook_attr_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.76), test)] +#[rustversion::attr(stable(1.78), test)] fn tests() { let t = trybuild::TestCases::new(); t.pass("tests/hook_attr/*-pass.rs"); diff --git a/packages/yew-macro/tests/hook_macro_test.rs b/packages/yew-macro/tests/hook_macro_test.rs index ebfaa3c05..f9f388799 100644 --- a/packages/yew-macro/tests/hook_macro_test.rs +++ b/packages/yew-macro/tests/hook_macro_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.76), test)] +#[rustversion::attr(stable(1.78), test)] fn tests() { let t = trybuild::TestCases::new(); t.pass("tests/hook_macro/*-pass.rs"); diff --git a/packages/yew-macro/tests/html_macro/block-fail.stderr b/packages/yew-macro/tests/html_macro/block-fail.stderr index a723ea940..7d94e954c 100644 --- a/packages/yew-macro/tests/html_macro/block-fail.stderr +++ b/packages/yew-macro/tests/html_macro/block-fail.stderr @@ -1,28 +1,24 @@ -error[E0277]: `()` doesn't implement `std::fmt::Display` +error[E0277]: the trait bound `(): Into>` is not satisfied --> tests/html_macro/block-fail.rs:6:15 | 6 | { () } | ^^ | | - | `()` cannot be formatted with the default formatter + | the trait `std::fmt::Display` is not implemented for `()`, which is required by `(): Into>` | required by a bound introduced by this call | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = note: required for `()` to implement `ToString` = note: required for `VNode` to implement `From<()>` = note: required for `()` to implement `Into` = note: 2 redundant requirements hidden = note: required for `()` to implement `Into>` -error[E0277]: `()` doesn't implement `std::fmt::Display` +error[E0277]: the trait bound `(): Into` is not satisfied --> tests/html_macro/block-fail.rs:15:17 | 15 | <>{ for (0..3).map(|_| not_tree()) } - | ^^^^^^ `()` cannot be formatted with the default formatter + | ^^^^^^ the trait `std::fmt::Display` is not implemented for `()`, which is required by `(): Into<_>` | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = note: required for `()` to implement `ToString` = note: required for `VNode` to implement `From<()>` = note: required for `()` to implement `Into` diff --git a/packages/yew-macro/tests/html_macro/component-any-children-pass.rs b/packages/yew-macro/tests/html_macro/component-any-children-pass.rs index d7b1ab3cb..527a115ec 100644 --- a/packages/yew-macro/tests/html_macro/component-any-children-pass.rs +++ b/packages/yew-macro/tests/html_macro/component-any-children-pass.rs @@ -1,5 +1,3 @@ -#![no_implicit_prelude] - // Shadow primitives #[allow(non_camel_case_types)] pub struct bool; diff --git a/packages/yew-macro/tests/html_macro/component-fail.stderr b/packages/yew-macro/tests/html_macro/component-fail.stderr index 051f546f2..df4d0e566 100644 --- a/packages/yew-macro/tests/html_macro/component-fail.stderr +++ b/packages/yew-macro/tests/html_macro/component-fail.stderr @@ -436,7 +436,10 @@ error[E0599]: no method named `r#type` found for struct `ChildPropertiesBuilder` | ---------- method `r#type` not found for this struct ... 85 | html! { }; - | ^^^^ method not found in `ChildPropertiesBuilder` + | ^^^^ + | +help: there is a method `type_id` with a similar name, but with different arguments + --> $RUST/core/src/any.rs error[E0609]: no field `unknown` on type `ChildProperties` --> tests/html_macro/component-fail.rs:88:20 @@ -568,22 +571,13 @@ note: required by a bound in `ChildPropertiesBuilder::int` | --- required by a bound in this associated function = note: this error originates in the derive macro `Properties` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `AssertAllProps: HasProp` is not satisfied +error[E0277]: not all required properties have been provided --> tests/html_macro/component-fail.rs:99:14 | 99 | html! { }; - | ^^^^^ the trait `HasProp` is not implemented for `AssertAllProps` + | ^^^^^ missing required properties for this component | - = help: the following other types implement trait `HasProp`: - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp<_ChildContainerProperties::children, HasChildContainerPropertieschildren>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - and $N others + = help: the trait `HasProp` is not implemented for `AssertAllProps`, which is required by `AssertAllProps: AllPropsFor` note: required for `CheckChildPropertiesAll` to implement `HasAllProps` --> tests/html_macro/component-fail.rs:4:17 | @@ -627,22 +621,13 @@ error[E0609]: no field `children` on type `ChildProperties` | = note: this error originates in the macro `html` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `AssertAllProps: HasProp<_ChildContainerProperties::children, _>` is not satisfied +error[E0277]: not all required properties have been provided --> tests/html_macro/component-fail.rs:115:14 | 115 | html! { }; - | ^^^^^^^^^^^^^^ the trait `HasProp<_ChildContainerProperties::children, _>` is not implemented for `AssertAllProps` + | ^^^^^^^^^^^^^^ missing required properties for this component | - = help: the following other types implement trait `HasProp`: - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp<_ChildContainerProperties::children, HasChildContainerPropertieschildren>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - and $N others + = help: the trait `HasProp<_ChildContainerProperties::children, _>` is not implemented for `AssertAllProps`, which is required by `AssertAllProps: AllPropsFor` note: required for `CheckChildContainerPropertiesAll` to implement `HasAllProps` --> tests/html_macro/component-fail.rs:24:17 | @@ -659,22 +644,13 @@ note: required by a bound in `yew::html::component::properties::__macro::PreBuil | ^^^^^^^^^^^^^^^^^^^ required by this bound in `PreBuild::::build` = note: this error originates in the macro `html` which comes from the expansion of the derive macro `Properties` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `AssertAllProps: HasProp<_ChildContainerProperties::children, _>` is not satisfied +error[E0277]: not all required properties have been provided --> tests/html_macro/component-fail.rs:116:14 | 116 | html! { }; - | ^^^^^^^^^^^^^^ the trait `HasProp<_ChildContainerProperties::children, _>` is not implemented for `AssertAllProps` + | ^^^^^^^^^^^^^^ missing required properties for this component | - = help: the following other types implement trait `HasProp`: - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp<_ChildContainerProperties::children, HasChildContainerPropertieschildren>> - as HasProp>> - as HasProp>> - as HasProp>> - as HasProp>> - and $N others + = help: the trait `HasProp<_ChildContainerProperties::children, _>` is not implemented for `AssertAllProps`, which is required by `AssertAllProps: AllPropsFor` note: required for `CheckChildContainerPropertiesAll` to implement `HasAllProps` --> tests/html_macro/component-fail.rs:24:17 | @@ -716,7 +692,7 @@ error[E0277]: the trait bound `VChild: From` is not satisfied --> tests/html_macro/component-fail.rs:118:29 | 118 | html! { <> }; - | ^ the trait `From` is not implemented for `VChild` + | ^ the trait `From` is not implemented for `VChild`, which is required by `VNode: Into<_>` | = note: required for `VNode` to implement `Into>` @@ -739,3 +715,11 @@ note: required by a bound in `ChildContainerPropertiesBuilder::children` 26 | pub children: ChildrenWithProps, | -------- required by a bound in this associated function = note: this error originates in the derive macro `Properties` (in Nightly builds, run with -Z macro-backtrace for more info) + +warning: unused variable: `props` + --> tests/html_macro/component-fail.rs:144:16 + | +144 | fn HtmlInProps(props: &HtmlInPropsProperties) -> Html { let _ = (); unimplemented!() } + | ^^^^^ help: if this is intentional, prefix it with an underscore: `_props` + | + = note: `#[warn(unused_variables)]` on by default diff --git a/packages/yew-macro/tests/html_macro/component-pass.rs b/packages/yew-macro/tests/html_macro/component-pass.rs index 5cc59c420..5b6ec617c 100644 --- a/packages/yew-macro/tests/html_macro/component-pass.rs +++ b/packages/yew-macro/tests/html_macro/component-pass.rs @@ -1,5 +1,3 @@ -#![no_implicit_prelude] - // Shadow primitives #[allow(non_camel_case_types)] pub struct bool; diff --git a/packages/yew-macro/tests/html_macro/component-unimplemented-fail.stderr b/packages/yew-macro/tests/html_macro/component-unimplemented-fail.stderr index 3a26724ac..39d722e65 100644 --- a/packages/yew-macro/tests/html_macro/component-unimplemented-fail.stderr +++ b/packages/yew-macro/tests/html_macro/component-unimplemented-fail.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Unimplemented: yew::Component` is not satisfied --> tests/html_macro/component-unimplemented-fail.rs:6:14 | 6 | html! { }; - | ^^^^^^^^^^^^^ the trait `yew::Component` is not implemented for `Unimplemented` + | ^^^^^^^^^^^^^ the trait `yew::Component` is not implemented for `Unimplemented`, which is required by `Unimplemented: BaseComponent` | = help: the trait `yew::Component` is implemented for `ContextProvider` = note: required for `Unimplemented` to implement `BaseComponent` @@ -17,6 +17,11 @@ error[E0599]: the function or associated item `new` exists for struct `VChild }; | ^^^^^^^^^^^^^ function or associated item cannot be called on `VChild` due to unsatisfied trait bounds | +note: if you're trying to build a new `VChild`, consider using `VChild::::new` which returns `VChild<_>` + --> $WORKSPACE/packages/yew/src/virtual_dom/vcomp.rs + | + | pub fn new(props: COMP::Properties, key: Option) -> Self { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: the following trait bounds were not satisfied: `Unimplemented: BaseComponent` note: the trait `BaseComponent` must be implemented diff --git a/packages/yew-macro/tests/html_macro/element-fail.stderr b/packages/yew-macro/tests/html_macro/element-fail.stderr index 6fb429a31..0156c5ac8 100644 --- a/packages/yew-macro/tests/html_macro/element-fail.stderr +++ b/packages/yew-macro/tests/html_macro/element-fail.stderr @@ -510,16 +510,15 @@ error[E0277]: the trait bound `Option<{integer}>: IntoPropValue as IntoPropValue>> as IntoPropValue>>> -error[E0277]: expected a `Fn(MouseEvent)` closure, found `{integer}` +error[E0277]: the trait bound `{integer}: IntoEventCallback` is not satisfied --> tests/html_macro/element-fail.rs:51:28 | 51 | html! { }; | -----------------------^----- | | | - | | expected an `Fn(MouseEvent)` closure, found `{integer}` + | | the trait `Fn<(MouseEvent,)>` is not implemented for `{integer}`, which is required by `{integer}: IntoEventCallback` | required by a bound introduced by this call | - = help: the trait `Fn<(MouseEvent,)>` is not implemented for `{integer}` = help: the following other types implement trait `IntoEventCallback`: yew::Callback Option> @@ -542,18 +541,19 @@ note: required by a bound in `yew::html::onclick::Wrapper::__macro_new` | required by this bound in `Wrapper::__macro_new` = note: this error originates in the macro `impl_action` which comes from the expansion of the macro `impl_short` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: expected a `Fn(MouseEvent)` closure, found `yew::Callback` +error[E0277]: the trait bound `yew::Callback: IntoEventCallback` is not satisfied --> tests/html_macro/element-fail.rs:52:29 | 52 | html! { }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------ | | | - | | expected an `Fn(MouseEvent)` closure, found `yew::Callback` + | | the trait `Fn<(MouseEvent,)>` is not implemented for `yew::Callback`, which is required by `yew::Callback: IntoEventCallback` | required by a bound introduced by this call | - = help: the trait `Fn<(MouseEvent,)>` is not implemented for `yew::Callback` = help: the following other types implement trait `IntoEventCallback`: yew::Callback + Option> + Option &yew::Callback = note: required for `yew::Callback` to implement `IntoEventCallback` note: required by a bound in `yew::html::onclick::Wrapper::__macro_new` @@ -631,18 +631,19 @@ error[E0277]: the trait bound `Option: IntoPropValue as IntoPropValue>> as IntoPropValue>>> -error[E0277]: expected a `Fn(MouseEvent)` closure, found `yew::Callback` +error[E0277]: the trait bound `yew::Callback: IntoEventCallback` is not satisfied --> tests/html_macro/element-fail.rs:58:29 | 58 | html! { }; | ------------------------^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------ | | | - | | expected an `Fn(MouseEvent)` closure, found `yew::Callback` + | | the trait `Fn<(MouseEvent,)>` is not implemented for `yew::Callback`, which is required by `yew::Callback: IntoEventCallback` | required by a bound introduced by this call | - = help: the trait `Fn<(MouseEvent,)>` is not implemented for `yew::Callback` = help: the following other types implement trait `IntoEventCallback`: yew::Callback + Option> + Option &yew::Callback = note: required for `yew::Callback` to implement `IntoEventCallback` note: required by a bound in `yew::html::onclick::Wrapper::__macro_new` @@ -694,7 +695,7 @@ error[E0277]: the trait bound `implicit_clone::unsync::string::IString: From<{in --> tests/html_macro/element-fail.rs:79:16 | 79 | html! { <@{55}> }; - | ^^ the trait `From<{integer}>` is not implemented for `implicit_clone::unsync::string::IString` + | ^^ the trait `From<{integer}>` is not implemented for `implicit_clone::unsync::string::IString`, which is required by `{integer}: Into` | = help: the following other types implement trait `From`: >> diff --git a/packages/yew-macro/tests/html_macro/iterable-fail.stderr b/packages/yew-macro/tests/html_macro/iterable-fail.stderr index 6b71efea4..5355dac4f 100644 --- a/packages/yew-macro/tests/html_macro/iterable-fail.stderr +++ b/packages/yew-macro/tests/html_macro/iterable-fail.stderr @@ -10,7 +10,7 @@ error[E0277]: `()` is not an iterator 5 | html! { for () }; | ^^ `()` is not an iterator | - = help: the trait `Iterator` is not implemented for `()` + = help: the trait `Iterator` is not implemented for `()`, which is required by `(): IntoIterator` = note: required for `()` to implement `IntoIterator` error[E0277]: `()` is not an iterator @@ -22,7 +22,7 @@ error[E0277]: `()` is not an iterator | |this tail expression is of type `()` | `()` is not an iterator | - = help: the trait `Iterator` is not implemented for `()` + = help: the trait `Iterator` is not implemented for `()`, which is required by `(): IntoIterator` = note: required for `()` to implement `IntoIterator` error[E0277]: `()` doesn't implement `std::fmt::Display` @@ -31,7 +31,7 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` 7 | html! { for Vec::<()>::new().into_iter() }; | ^^^ `()` cannot be formatted with the default formatter | - = help: the trait `std::fmt::Display` is not implemented for `()` + = help: the trait `std::fmt::Display` is not implemented for `()`, which is required by `VNode: FromIterator<_>` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = help: the trait `FromIterator` is implemented for `VNode` = note: required for `()` to implement `ToString` @@ -47,7 +47,7 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` 10 | html! { for empty }; | ^^^^^ `()` cannot be formatted with the default formatter | - = help: the trait `std::fmt::Display` is not implemented for `()` + = help: the trait `std::fmt::Display` is not implemented for `()`, which is required by `VNode: FromIterator<_>` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = help: the trait `FromIterator` is implemented for `VNode` = note: required for `()` to implement `ToString` @@ -63,7 +63,7 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` 13 | html! { for empty.iter() }; | ^^^^^ `()` cannot be formatted with the default formatter | - = help: the trait `std::fmt::Display` is not implemented for `()` + = help: the trait `std::fmt::Display` is not implemented for `()`, which is required by `VNode: FromIterator<_>` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = help: the trait `FromIterator` is implemented for `VNode` = note: required for `&()` to implement `std::fmt::Display` @@ -80,7 +80,7 @@ error[E0277]: `()` is not an iterator 18 | { for () } | ^^ `()` is not an iterator | - = help: the trait `Iterator` is not implemented for `()` + = help: the trait `Iterator` is not implemented for `()`, which is required by `(): IntoIterator` = note: required for `()` to implement `IntoIterator` note: required by a bound in `into_node_iter` --> $WORKSPACE/packages/yew/src/utils/mod.rs @@ -90,3 +90,26 @@ note: required by a bound in `into_node_iter` | where | IT: IntoIterator, | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `into_node_iter` + +error[E0277]: `()` is not an iterator + --> tests/html_macro/iterable-fail.rs:15:5 + | +15 | / html! { +16 | | <> +17 | |
+18 | | { for () } +19 | | +20 | | }; + | |_____^ `()` is not an iterator + | + = help: the trait `Iterator` is not implemented for `()`, which is required by `(): IntoIterator` + = note: required for `()` to implement `IntoIterator` +note: required by a bound in `into_node_iter` + --> $WORKSPACE/packages/yew/src/utils/mod.rs + | + | pub fn into_node_iter(it: IT) -> impl Iterator + | -------------- required by a bound in this function + | where + | IT: IntoIterator, + | ^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `into_node_iter` + = note: this error originates in the macro `html` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/packages/yew-macro/tests/html_macro/missing-props-diagnostics-fail.rs b/packages/yew-macro/tests/html_macro/missing-props-diagnostics-fail.rs new file mode 100644 index 000000000..6b66c44f8 --- /dev/null +++ b/packages/yew-macro/tests/html_macro/missing-props-diagnostics-fail.rs @@ -0,0 +1,35 @@ +use yew::prelude::*; + +#[function_component] +pub fn App() -> Html { + html! { + + } +} + +#[function_component] +pub fn App1() -> Html { + html! { + + } +} + +#[function_component] +pub fn App2() -> Html { + html! { + + } +} + +#[derive(Properties, PartialEq, Clone)] +pub struct FooProps { + pub bar: String, + pub baz: u32, +} + +#[function_component] +pub fn Foo(_props: &FooProps) -> Html { + html! {} +} + +fn main() {} \ No newline at end of file diff --git a/packages/yew-macro/tests/html_macro/missing-props-diagnostics-fail.stderr b/packages/yew-macro/tests/html_macro/missing-props-diagnostics-fail.stderr new file mode 100644 index 000000000..d99d9511c --- /dev/null +++ b/packages/yew-macro/tests/html_macro/missing-props-diagnostics-fail.stderr @@ -0,0 +1,83 @@ +error[E0277]: not all required properties have been provided + --> tests/html_macro/missing-props-diagnostics-fail.rs:6:10 + | +6 | + | ^^^ missing required properties for this component + | + = help: the trait `HasProp` is not implemented for `AssertAllProps`, which is required by `AssertAllProps: AllPropsFor` +note: required for `CheckFooPropsAll` to implement `HasAllProps` + --> tests/html_macro/missing-props-diagnostics-fail.rs:24:10 + | +24 | #[derive(Properties, PartialEq, Clone)] + | ^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro + = note: required for `AssertAllProps` to implement `AllPropsFor` +note: required by a bound in `yew::html::component::properties::__macro::PreBuild::::build` + --> $WORKSPACE/packages/yew/src/html/component/properties.rs + | + | pub fn build(self) -> B::Output + | ----- required by a bound in this associated function + | where + | Token: AllPropsFor, + | ^^^^^^^^^^^^^^^^^^^ required by this bound in `PreBuild::::build` + = note: this error originates in the macro `html` which comes from the expansion of the derive macro `Properties` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: not all required properties have been provided + --> tests/html_macro/missing-props-diagnostics-fail.rs:6:10 + | +6 | + | ^^^ missing required properties for this component + | + = help: the trait `HasProp` is not implemented for `AssertAllProps`, which is required by `AssertAllProps: AllPropsFor` +note: required for `CheckFooPropsAll` to implement `HasAllProps` + --> tests/html_macro/missing-props-diagnostics-fail.rs:24:10 + | +24 | #[derive(Properties, PartialEq, Clone)] + | ^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro + = note: required for `AssertAllProps` to implement `AllPropsFor` +note: required by a bound in `yew::html::component::properties::__macro::PreBuild::::build` + --> $WORKSPACE/packages/yew/src/html/component/properties.rs + | + | pub fn build(self) -> B::Output + | ----- required by a bound in this associated function + | where + | Token: AllPropsFor, + | ^^^^^^^^^^^^^^^^^^^ required by this bound in `PreBuild::::build` + = note: this error originates in the macro `html` which comes from the expansion of the derive macro `Properties` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: property `baz` is required but not provided + --> tests/html_macro/missing-props-diagnostics-fail.rs:13:10 + | +13 | + | ^^^ missing required property `baz` + | + = help: the trait `HasProp` is not implemented for `AssertAllProps`, which is required by `HasFooPropsbar: AllPropsFor` + = help: the following other types implement trait `HasProp`: + as HasProp>> + as HasProp>> + as HasProp>> + as HasProp>> + as HasProp>> + as HasProp>> + as HasProp>> + as HasProp>> + and $N others +note: required for `HasFooPropsbar` to implement `HasProp>` + --> tests/html_macro/missing-props-diagnostics-fail.rs:24:10 + | +24 | #[derive(Properties, PartialEq, Clone)] + | ^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro +note: required for `CheckFooPropsAll>` to implement `HasAllProps, &dyn HasProp)>` + --> tests/html_macro/missing-props-diagnostics-fail.rs:24:10 + | +24 | #[derive(Properties, PartialEq, Clone)] + | ^^^^^^^^^^ unsatisfied trait bound introduced in this `derive` macro + = note: required for `HasFooPropsbar` to implement `AllPropsFor, &dyn HasProp)>` +note: required by a bound in `yew::html::component::properties::__macro::PreBuild::::build` + --> $WORKSPACE/packages/yew/src/html/component/properties.rs + | + | pub fn build(self) -> B::Output + | ----- required by a bound in this associated function + | where + | Token: AllPropsFor, + | ^^^^^^^^^^^^^^^^^^^ required by this bound in `PreBuild::::build` + = note: this error originates in the macro `html` which comes from the expansion of the derive macro `Properties` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/packages/yew-macro/tests/html_macro/node-fail.stderr b/packages/yew-macro/tests/html_macro/node-fail.stderr index 05676a5c9..f2d02cdef 100644 --- a/packages/yew-macro/tests/html_macro/node-fail.stderr +++ b/packages/yew-macro/tests/html_macro/node-fail.stderr @@ -29,13 +29,6 @@ error[E0425]: cannot find value `invalid` in this scope | 7 | html! { invalid }; | ^^^^^^^ not found in this scope - | -help: consider importing one of these items - | -1 + use core::ptr::invalid; - | -1 + use std::ptr::invalid; - | error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/node-fail.rs:6:13 @@ -43,7 +36,7 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` 6 | html! { () }; | ^^ `()` cannot be formatted with the default formatter | - = help: the trait `std::fmt::Display` is not implemented for `()` + = help: the trait `std::fmt::Display` is not implemented for `()`, which is required by `VNode: From<()>` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = help: the following other types implement trait `From`: > @@ -65,7 +58,7 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` 17 | not_node() | ^^^^^^^^ `()` cannot be formatted with the default formatter | - = help: the trait `std::fmt::Display` is not implemented for `()` + = help: the trait `std::fmt::Display` is not implemented for `()`, which is required by `VNode: From<()>` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = help: the following other types implement trait `From`: > diff --git a/packages/yew-macro/tests/html_macro_test.rs b/packages/yew-macro/tests/html_macro_test.rs index 7b410d8aa..fd04bfe0e 100644 --- a/packages/yew-macro/tests/html_macro_test.rs +++ b/packages/yew-macro/tests/html_macro_test.rs @@ -1,7 +1,7 @@ use yew::{html, html_nested}; #[allow(dead_code)] -#[rustversion::attr(stable(1.76), test)] +#[rustversion::attr(stable(1.78), test)] fn html_macro() { let t = trybuild::TestCases::new(); diff --git a/packages/yew-macro/tests/props_macro/props-pass.rs b/packages/yew-macro/tests/props_macro/props-pass.rs index 4e1186d93..09ba84050 100644 --- a/packages/yew-macro/tests/props_macro/props-pass.rs +++ b/packages/yew-macro/tests/props_macro/props-pass.rs @@ -1,4 +1,3 @@ -#![no_implicit_prelude] // Shadow primitives #[allow(non_camel_case_types)] diff --git a/packages/yew-macro/tests/props_macro/resolve-prop-fail.stderr b/packages/yew-macro/tests/props_macro/resolve-prop-fail.stderr index 1ea3b7589..daf3e1642 100644 --- a/packages/yew-macro/tests/props_macro/resolve-prop-fail.stderr +++ b/packages/yew-macro/tests/props_macro/resolve-prop-fail.stderr @@ -22,7 +22,7 @@ error[E0277]: can't compare `Props` with `Props` 9 | type Properties = Props; | ^^^^^ no implementation for `Props == Props` | - = help: the trait `PartialEq` is not implemented for `Props` + = help: the trait `PartialEq` is not implemented for `Props`, which is required by `::Properties: yew::Properties` = help: the following other types implement trait `yew::Properties`: Props ContextProviderProps @@ -40,3 +40,52 @@ help: consider annotating `Props` with `#[derive(PartialEq)]` 4 + #[derive(PartialEq)] 5 | struct Props {} | + +error[E0277]: the trait bound `Vec<_>: yew::Properties` is not satisfied + --> tests/props_macro/resolve-prop-fail.rs:29:17 + | +29 | yew::props!(Vec<_> {}); + | ^^^^^^ the trait `yew::Properties` is not implemented for `Vec<_>` + | + = help: the following other types implement trait `yew::Properties`: + Props + ContextProviderProps + ChildrenProps + SuspenseProps + () + +error[E0277]: the trait bound `Vec<_>: yew::Properties` is not satisfied + --> tests/props_macro/resolve-prop-fail.rs:29:17 + | +29 | yew::props!(Vec<_> {}); + | ^^^ the trait `yew::Properties` is not implemented for `Vec<_>` + | + = help: the following other types implement trait `yew::Properties`: + Props + ContextProviderProps + ChildrenProps + SuspenseProps + () + +error[E0277]: the trait bound `MyComp: yew::Properties` is not satisfied + --> tests/props_macro/resolve-prop-fail.rs:30:17 + | +30 | yew::props!(MyComp {}); + | ^^^^^^ the trait `yew::Properties` is not implemented for `MyComp` + | + = help: the following other types implement trait `yew::Properties`: + Props + ContextProviderProps + ChildrenProps + SuspenseProps + () + +error[E0277]: the trait bound `MyNotAComponent: yew::Component` is not satisfied + --> tests/props_macro/resolve-prop-fail.rs:31:17 + | +31 | yew::props!(MyNotAComponent::Properties {}); + | ^^^^^^^^^^^^^^^ the trait `yew::Component` is not implemented for `MyNotAComponent` + | + = help: the following other types implement trait `yew::Component`: + MyComp + ContextProvider diff --git a/packages/yew-macro/tests/props_macro/resolve-prop-pass.rs b/packages/yew-macro/tests/props_macro/resolve-prop-pass.rs index 34ba0c83f..3a387732f 100644 --- a/packages/yew-macro/tests/props_macro/resolve-prop-pass.rs +++ b/packages/yew-macro/tests/props_macro/resolve-prop-pass.rs @@ -1,4 +1,3 @@ -#![no_implicit_prelude] // Shadow primitives #[allow(non_camel_case_types)] diff --git a/packages/yew-macro/tests/props_macro_test.rs b/packages/yew-macro/tests/props_macro_test.rs index 008b161d5..75e0ee81d 100644 --- a/packages/yew-macro/tests/props_macro_test.rs +++ b/packages/yew-macro/tests/props_macro_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.76), test)] +#[rustversion::attr(stable(1.78), test)] fn props_macro() { let t = trybuild::TestCases::new(); t.pass("tests/props_macro/*-pass.rs"); diff --git a/packages/yew-router-macro/Cargo.toml b/packages/yew-router-macro/Cargo.toml index 550b84f58..b11b5bfde 100644 --- a/packages/yew-router-macro/Cargo.toml +++ b/packages/yew-router-macro/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" license = "MIT OR Apache-2.0" description = "Contains macros used with yew-router" repository = "https://github.com/yewstack/yew" -rust-version = "1.76.0" +rust-version = "1.78.0" [lib] proc-macro = true diff --git a/packages/yew-router-macro/Makefile.toml b/packages/yew-router-macro/Makefile.toml index c19428373..27aa86f6a 100644 --- a/packages/yew-router-macro/Makefile.toml +++ b/packages/yew-router-macro/Makefile.toml @@ -1,6 +1,6 @@ [tasks.test] clear = true -toolchain = "1.76.0" +toolchain = "1.78.0" command = "cargo" args = ["test"] diff --git a/packages/yew-router-macro/tests/routable_derive_test.rs b/packages/yew-router-macro/tests/routable_derive_test.rs index e57f58fdb..2da897577 100644 --- a/packages/yew-router-macro/tests/routable_derive_test.rs +++ b/packages/yew-router-macro/tests/routable_derive_test.rs @@ -1,5 +1,5 @@ #[allow(dead_code)] -#[rustversion::attr(stable(1.76), test)] +#[rustversion::attr(stable(1.78), test)] fn tests() { let t = trybuild::TestCases::new(); t.pass("tests/routable_derive/*-pass.rs"); diff --git a/packages/yew-router/Cargo.toml b/packages/yew-router/Cargo.toml index 6bc0fb4b2..989da5e75 100644 --- a/packages/yew-router/Cargo.toml +++ b/packages/yew-router/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["web", "yew", "router"] categories = ["gui", "web-programming"] description = "A router implementation for the Yew framework" repository = "https://github.com/yewstack/yew" -rust-version = "1.76.0" +rust-version = "1.78.0" [dependencies] yew = { version = "0.21.0", path = "../yew", default-features= false } diff --git a/packages/yew/Cargo.toml b/packages/yew/Cargo.toml index cb41df357..696463e75 100644 --- a/packages/yew/Cargo.toml +++ b/packages/yew/Cargo.toml @@ -14,7 +14,7 @@ keywords = ["web", "webasm", "javascript"] categories = ["gui", "wasm", "web-programming"] description = "A framework for creating reliable and efficient web applications" readme = "../../README.md" -rust-version = "1.76.0" +rust-version = "1.78.0" [dependencies] console_error_panic_hook = "0.1" diff --git a/packages/yew/src/html/component/properties.rs b/packages/yew/src/html/component/properties.rs index d61915339..2e347732a 100644 --- a/packages/yew/src/html/component/properties.rs +++ b/packages/yew/src/html/component/properties.rs @@ -25,6 +25,10 @@ mod __macro { /// previously (represented by the tail) is still set after P has been set. /// - ^ the two impls would be overlapping, where it not for the `How` argument, which resolves /// the conflict. + #[diagnostic::on_unimplemented( + message = "property `{P}` is required but not provided", + label = "missing required property `{P}`" + )] pub trait HasProp {} /// A marker trait to ensure that the builder has received all required props. @@ -32,6 +36,10 @@ mod __macro { /// all properties marked as required as a bound on the impl. /// /// [`Properties`]: super::Properties + #[diagnostic::on_unimplemented( + message = "not all required properties have been provided for `{P}`", + label = "missing required properties" + )] pub trait HasAllProps {} /// Trait finishing the builder and verifying all props were set. @@ -81,6 +89,10 @@ mod __macro { /// Trait to specify the requirement for Self to be a valid token signaling all props have been /// provided to the builder. + #[diagnostic::on_unimplemented( + message = "not all required properties have been provided", + label = "missing required properties for this component" + )] pub trait AllPropsFor {} impl, How> AllPropsFor for Token where diff --git a/tools/build-examples/src/bin/update-wasm-opt.rs b/tools/build-examples/src/bin/update-wasm-opt.rs index 749dd5c49..3d3b5c2b6 100644 --- a/tools/build-examples/src/bin/update-wasm-opt.rs +++ b/tools/build-examples/src/bin/update-wasm-opt.rs @@ -50,10 +50,7 @@ fn main() -> ExitCode { } if outdated_examples.is_empty() { - println!( - "All examples are up-to-date with the latest wasm_opt version: {}", - latest_wasm_opt - ); + println!("All examples are up-to-date with the latest wasm_opt version: {latest_wasm_opt}"); return ExitCode::from(0); } @@ -62,16 +59,13 @@ fn main() -> ExitCode { outdated_examples.len() ); for example in &outdated_examples { - println!(" - {}", example); + println!(" - {example}"); } - println!("Latest wasm_opt version is: {}", latest_wasm_opt); + println!("Latest wasm_opt version is: {latest_wasm_opt}"); println!("Updating all examples..."); let updated_count = update_all_examples(&outdated_example_paths, &latest_wasm_opt); - println!( - "Updated {} example configurations to use {}", - updated_count, latest_wasm_opt - ); + println!("Updated {updated_count} example configurations to use {latest_wasm_opt}"); ExitCode::from(0) } @@ -90,8 +84,7 @@ pub fn update_all_examples(outdated_paths: &[PathBuf], latest_version: &str) -> re.replace(&content, |_: ®ex::Captures| { format!( r#"[tools] -wasm_opt = "{}""#, - latest_version +wasm_opt = "{latest_version}""# ) }) .to_string() @@ -100,8 +93,7 @@ wasm_opt = "{}""#, if content.is_empty() { format!( r#"[tools] -wasm_opt = "{}""#, - latest_version +wasm_opt = "{latest_version}""# ) } else { format!( diff --git a/tools/build-examples/src/lib.rs b/tools/build-examples/src/lib.rs index 7e2782e92..e980657ae 100644 --- a/tools/build-examples/src/lib.rs +++ b/tools/build-examples/src/lib.rs @@ -32,10 +32,7 @@ pub fn get_latest_wasm_opt_version() -> String { .text() .unwrap_or_else(|_| "Could not read error response".to_string()); - panic!( - "GitHub API request failed with status: {}. Details: {}", - status, error_text - ); + panic!("GitHub API request failed with status: {status}. Details: {error_text}"); } let release: GitHubRelease = res.json().expect("Failed to parse GitHub API response"); diff --git a/tools/build-examples/src/main.rs b/tools/build-examples/src/main.rs index 943ee5086..c618bf80d 100644 --- a/tools/build-examples/src/main.rs +++ b/tools/build-examples/src/main.rs @@ -54,10 +54,10 @@ fn main() -> ExitCode { outdated_example_paths.push(path.clone()); } - println!("::group::Building {}", example); + println!("::group::Building {example}"); if !build_example(&path, &output_dir, &example) { - eprintln!("::error ::{} failed to build", example); + eprintln!("::error ::{example} failed to build"); failure = true; } @@ -105,7 +105,7 @@ fn build_example(path: &Path, output_dir: &Path, example: &str) -> bool { .arg("--dist") .arg(&dist_dir) .arg("--public-url") - .arg(format!("{}/{}", public_url_prefix, example)) + .arg(format!("{public_url_prefix}/{example}")) .arg("--no-sri") .status(); diff --git a/website/docs/getting-started/introduction.mdx b/website/docs/getting-started/introduction.mdx index 2f16480ef..7e9f4de0c 100644 --- a/website/docs/getting-started/introduction.mdx +++ b/website/docs/getting-started/introduction.mdx @@ -11,7 +11,7 @@ bundler for Rust. To install Rust, follow the [official instructions](https://www.rust-lang.org/tools/install). :::important -The minimum supported Rust version (MSRV) for Yew is `1.76.0`. Older versions will not compile. +The minimum supported Rust version (MSRV) for Yew is `1.78.0`. Older versions will not compile. You can check your toolchain version using `rustup show` (under "active toolchain") or `rustc --version`. To update your toolchain, run `rustup update`. diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx index 9f4da950d..904ddda1c 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx +++ b/website/i18n/ja/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx @@ -9,7 +9,7 @@ Yew アプリケーションをコンパイル、ビルド、パッケージ、 Rust をインストールするには、[公式の手順](https://www.rust-lang.org/tools/install) に従ってください。 :::important -Yew がサポートする最低 Rust バージョン(MSRV)は `1.76.0` です。古いバージョンではコンパイルできません。`rustup show`(「active toolchain」の下)または `rustc --version` を使用してツールチェーンのバージョンを確認できます。ツールチェーンを更新するには、`rustup update` を実行してください。 +Yew がサポートする最低 Rust バージョン(MSRV)は `1.78.0` です。古いバージョンではコンパイルできません。`rustup show`(「active toolchain」の下)または `rustc --version` を使用してツールチェーンのバージョンを確認できます。ツールチェーンを更新するには、`rustup update` を実行してください。 ::: ## WebAssembly ターゲットのインストール diff --git a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx index 9f4da950d..904ddda1c 100644 --- a/website/i18n/ja/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx +++ b/website/i18n/ja/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx @@ -9,7 +9,7 @@ Yew アプリケーションをコンパイル、ビルド、パッケージ、 Rust をインストールするには、[公式の手順](https://www.rust-lang.org/tools/install) に従ってください。 :::important -Yew がサポートする最低 Rust バージョン(MSRV)は `1.76.0` です。古いバージョンではコンパイルできません。`rustup show`(「active toolchain」の下)または `rustc --version` を使用してツールチェーンのバージョンを確認できます。ツールチェーンを更新するには、`rustup update` を実行してください。 +Yew がサポートする最低 Rust バージョン(MSRV)は `1.78.0` です。古いバージョンではコンパイルできません。`rustup show`(「active toolchain」の下)または `rustc --version` を使用してツールチェーンのバージョンを確認できます。ツールチェーンを更新するには、`rustup update` を実行してください。 ::: ## WebAssembly ターゲットのインストール diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx index 4a8ff4ac1..eb3665786 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx @@ -9,7 +9,7 @@ title: '开始使用' 要安装 Rust,请按照[官方说明](https://www.rust-lang.org/tools/install)。 :::important -Yew 支持的最低 Rust 版本(MSRV)是 `1.76.0`。旧版本将无法编译。您可以使用 `rustup show`(在“active toolchain”下)或 `rustc --version` 检查您的工具链版本。要更新您的工具链,请运行 `rustup update`。 +Yew 支持的最低 Rust 版本(MSRV)是 `1.78.0`。旧版本将无法编译。您可以使用 `rustup show`(在“active toolchain”下)或 `rustc --version` 检查您的工具链版本。要更新您的工具链,请运行 `rustup update`。 ::: ## 安装 WebAssembly 目标 diff --git a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx index 4a8ff4ac1..eb3665786 100644 --- a/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx +++ b/website/i18n/zh-Hans/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx @@ -9,7 +9,7 @@ title: '开始使用' 要安装 Rust,请按照[官方说明](https://www.rust-lang.org/tools/install)。 :::important -Yew 支持的最低 Rust 版本(MSRV)是 `1.76.0`。旧版本将无法编译。您可以使用 `rustup show`(在“active toolchain”下)或 `rustc --version` 检查您的工具链版本。要更新您的工具链,请运行 `rustup update`。 +Yew 支持的最低 Rust 版本(MSRV)是 `1.78.0`。旧版本将无法编译。您可以使用 `rustup show`(在“active toolchain”下)或 `rustc --version` 检查您的工具链版本。要更新您的工具链,请运行 `rustup update`。 ::: ## 安装 WebAssembly 目标 diff --git a/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx b/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx index 50e3630b0..9eea3308f 100644 --- a/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx +++ b/website/i18n/zh-Hant/docusaurus-plugin-content-docs/current/getting-started/introduction.mdx @@ -9,7 +9,7 @@ title: '開始使用' 要安裝 Rust,請按照[官方說明](https://www.rust-lang.org/tools/install)。 :::important -Yew 支援的最低 Rust 版本(MSRV)是 `1.76.0`。舊版將無法編譯。您可以使用 `rustup show`(在「active toolchain」下)或 `rustc --version` 檢查您的工具鏈版本。若要更新您的工具鏈,請執行 `rustup update`。 +Yew 支援的最低 Rust 版本(MSRV)是 `1.78.0`。舊版將無法編譯。您可以使用 `rustup show`(在「active toolchain」下)或 `rustc --version` 檢查您的工具鏈版本。若要更新您的工具鏈,請執行 `rustup update`。 ::: ## 安裝 WebAssembly 目標 diff --git a/website/i18n/zh-Hant/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx b/website/i18n/zh-Hant/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx index 50e3630b0..9eea3308f 100644 --- a/website/i18n/zh-Hant/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx +++ b/website/i18n/zh-Hant/docusaurus-plugin-content-docs/version-0.22/getting-started/introduction.mdx @@ -9,7 +9,7 @@ title: '開始使用' 要安裝 Rust,請按照[官方說明](https://www.rust-lang.org/tools/install)。 :::important -Yew 支援的最低 Rust 版本(MSRV)是 `1.76.0`。舊版將無法編譯。您可以使用 `rustup show`(在「active toolchain」下)或 `rustc --version` 檢查您的工具鏈版本。若要更新您的工具鏈,請執行 `rustup update`。 +Yew 支援的最低 Rust 版本(MSRV)是 `1.78.0`。舊版將無法編譯。您可以使用 `rustup show`(在「active toolchain」下)或 `rustc --version` 檢查您的工具鏈版本。若要更新您的工具鏈,請執行 `rustup update`。 ::: ## 安裝 WebAssembly 目標 diff --git a/website/versioned_docs/version-0.22/getting-started/introduction.mdx b/website/versioned_docs/version-0.22/getting-started/introduction.mdx index 2f16480ef..7e9f4de0c 100644 --- a/website/versioned_docs/version-0.22/getting-started/introduction.mdx +++ b/website/versioned_docs/version-0.22/getting-started/introduction.mdx @@ -11,7 +11,7 @@ bundler for Rust. To install Rust, follow the [official instructions](https://www.rust-lang.org/tools/install). :::important -The minimum supported Rust version (MSRV) for Yew is `1.76.0`. Older versions will not compile. +The minimum supported Rust version (MSRV) for Yew is `1.78.0`. Older versions will not compile. You can check your toolchain version using `rustup show` (under "active toolchain") or `rustc --version`. To update your toolchain, run `rustup update`.