From 5aa203433e5d2557afee5988aebc759cb483d47d Mon Sep 17 00:00:00 2001 From: Anuvrat Date: Sat, 15 Jan 2022 20:11:44 +0530 Subject: [PATCH 1/4] Adds ContextHandle in yew::prelude --- packages/yew/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yew/src/lib.rs b/packages/yew/src/lib.rs index 8c493a26861..619bfa6b759 100644 --- a/packages/yew/src/lib.rs +++ b/packages/yew/src/lib.rs @@ -376,7 +376,7 @@ where pub mod prelude { pub use crate::app_handle::AppHandle; pub use crate::callback::Callback; - pub use crate::context::ContextProvider; + pub use crate::context::{ContextProvider, ContextHandle}; pub use crate::events::*; pub use crate::html::{ create_portal, BaseComponent, Children, ChildrenWithProps, Classes, Component, Context, From abdf21f2d523ac2df56cca3d29f8860dbefc5cc5 Mon Sep 17 00:00:00 2001 From: Anuvrat Date: Sat, 15 Jan 2022 21:32:14 +0530 Subject: [PATCH 2/4] Adds ContextHandle in yew::prelude Added ContextHandle in /yew/src/lib.rs and updated stderr with test-overwrite --- .../yew-macro/tests/derive_props/fail.stderr | 16 +++++++++++++++ .../tests/html_macro/block-fail.stderr | 8 ++++++++ .../tests/html_macro/component-fail.stderr | 12 +++++++++++ .../tests/html_macro/element-fail.stderr | 4 ++++ .../tests/html_macro/iterable-fail.stderr | 20 +++++++++++++++++++ .../tests/html_macro/node-fail.stderr | 8 ++++++++ 6 files changed, 68 insertions(+) diff --git a/packages/yew-macro/tests/derive_props/fail.stderr b/packages/yew-macro/tests/derive_props/fail.stderr index a56dbe6ccd0..79a4a902ca9 100644 --- a/packages/yew-macro/tests/derive_props/fail.stderr +++ b/packages/yew-macro/tests/derive_props/fail.stderr @@ -51,6 +51,10 @@ error[E0277]: the trait bound `Value: Default` is not satisfied | ^^^^^^^^^^ the trait `Default` is not implemented for `Value` | note: required by `Option::::unwrap_or_default` + --> $RUST/core/src/option.rs + | + | pub fn unwrap_or_default(self) -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = 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` @@ -99,6 +103,10 @@ error[E0277]: expected a `FnOnce<()>` closure, found `{integer}` = help: the trait `FnOnce<()>` is not implemented for `{integer}` = note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `Option::::unwrap_or_else` + --> $RUST/core/src/option.rs + | + | pub fn unwrap_or_else T>(self, f: F) -> T { + | ^ required by this bound in `Option::::unwrap_or_else` error[E0593]: function is expected to take 0 arguments, but it takes 1 argument --> tests/derive_props/fail.rs:97:24 @@ -110,6 +118,10 @@ error[E0593]: function is expected to take 0 arguments, but it takes 1 argument | -------------------------- takes 1 argument | note: required by a bound in `Option::::unwrap_or_else` + --> $RUST/core/src/option.rs + | + | pub fn unwrap_or_else T>(self, f: F) -> T { + | ^ required by this bound in `Option::::unwrap_or_else` error[E0271]: type mismatch resolving ` i32 {t10::foo} as FnOnce<()>>::Output == String` --> tests/derive_props/fail.rs:111:24 @@ -118,3 +130,7 @@ error[E0271]: type mismatch resolving ` i32 {t10::foo} as FnOnce<()>>::O | ^^^ expected struct `String`, found `i32` | note: required by `Option::::unwrap_or_else` + --> $RUST/core/src/option.rs + | + | pub fn unwrap_or_else T>(self, f: F) -> T { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/packages/yew-macro/tests/html_macro/block-fail.stderr b/packages/yew-macro/tests/html_macro/block-fail.stderr index 0f7099ee5b9..fbf2c27503c 100644 --- a/packages/yew-macro/tests/html_macro/block-fail.stderr +++ b/packages/yew-macro/tests/html_macro/block-fail.stderr @@ -12,6 +12,10 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: 2 redundant requirements hidden = note: required because of the requirements on the impl of `Into>` for `()` note: required by `into` + --> $RUST/core/src/convert/mod.rs + | + | fn into(self) -> T; + | ^^^^^^^^^^^^^^^^^^^ error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/block-fail.rs:12:16 @@ -27,6 +31,10 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: 2 redundant requirements hidden = note: required because of the requirements on the impl of `Into>` for `()` note: required by `into` + --> $RUST/core/src/convert/mod.rs + | + | fn into(self) -> T; + | ^^^^^^^^^^^^^^^^^^^ error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/block-fail.rs:15:17 diff --git a/packages/yew-macro/tests/html_macro/component-fail.stderr b/packages/yew-macro/tests/html_macro/component-fail.stderr index 3a0eb2af361..175a8776a93 100644 --- a/packages/yew-macro/tests/html_macro/component-fail.stderr +++ b/packages/yew-macro/tests/html_macro/component-fail.stderr @@ -442,6 +442,10 @@ error[E0277]: the trait bound `VChild: From` is | = note: required because of the requirements on the impl of `Into>` for `yew::virtual_dom::VText` note: required by `into` + --> $RUST/core/src/convert/mod.rs + | + | fn into(self) -> T; + | ^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `VChild: From` is not satisfied --> tests/html_macro/component-fail.rs:102:29 @@ -451,6 +455,10 @@ error[E0277]: the trait bound `VChild: From` is not satisfied | = note: required because of the requirements on the impl of `Into>` for `VNode` note: required by `into` + --> $RUST/core/src/convert/mod.rs + | + | fn into(self) -> T; + | ^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `VChild: From` is not satisfied --> tests/html_macro/component-fail.rs:103:30 @@ -460,3 +468,7 @@ error[E0277]: the trait bound `VChild: From` is not satisfied | = note: required because of the requirements on the impl of `Into>` for `VNode` note: required by `into` + --> $RUST/core/src/convert/mod.rs + | + | fn into(self) -> T; + | ^^^^^^^^^^^^^^^^^^^ diff --git a/packages/yew-macro/tests/html_macro/element-fail.stderr b/packages/yew-macro/tests/html_macro/element-fail.stderr index 0ef61f0b6e5..467cd3e84df 100644 --- a/packages/yew-macro/tests/html_macro/element-fail.stderr +++ b/packages/yew-macro/tests/html_macro/element-fail.stderr @@ -486,3 +486,7 @@ error[E0277]: the trait bound `Cow<'static, str>: From<{integer}>` is not satisf and 14 others = note: required because of the requirements on the impl of `Into>` for `{integer}` note: required by `into` + --> $RUST/core/src/convert/mod.rs + | + | fn into(self) -> T; + | ^^^^^^^^^^^^^^^^^^^ diff --git a/packages/yew-macro/tests/html_macro/iterable-fail.stderr b/packages/yew-macro/tests/html_macro/iterable-fail.stderr index b1702551117..21ed58c89c4 100644 --- a/packages/yew-macro/tests/html_macro/iterable-fail.stderr +++ b/packages/yew-macro/tests/html_macro/iterable-fail.stderr @@ -13,6 +13,10 @@ error[E0277]: `()` is not an iterator = help: the trait `Iterator` is not implemented for `()` = note: required because of the requirements on the impl of `IntoIterator` for `()` note: required by `into_iter` + --> $RUST/core/src/iter/traits/collect.rs + | + | fn into_iter(self) -> Self::IntoIter; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `()` is not an iterator --> tests/html_macro/iterable-fail.rs:6:17 @@ -23,6 +27,10 @@ error[E0277]: `()` is not an iterator = help: the trait `Iterator` is not implemented for `()` = note: required because of the requirements on the impl of `IntoIterator` for `()` note: required by `into_iter` + --> $RUST/core/src/iter/traits/collect.rs + | + | fn into_iter(self) -> Self::IntoIter; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/iterable-fail.rs:7:17 @@ -37,6 +45,10 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: required because of the requirements on the impl of `Into` for `()` = note: required because of the requirements on the impl of `FromIterator<()>` for `VNode` note: required by a bound in `collect` + --> $RUST/core/src/iter/traits/iterator.rs + | + | Self: Sized, + | ^^^^^ required by this bound in `collect` error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/iterable-fail.rs:10:17 @@ -51,6 +63,10 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: required because of the requirements on the impl of `Into` for `()` = note: required because of the requirements on the impl of `FromIterator<()>` for `VNode` note: required by a bound in `collect` + --> $RUST/core/src/iter/traits/iterator.rs + | + | Self: Sized, + | ^^^^^ required by this bound in `collect` error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/iterable-fail.rs:13:17 @@ -66,6 +82,10 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: required because of the requirements on the impl of `Into` for `&()` = note: required because of the requirements on the impl of `FromIterator<&()>` for `VNode` note: required by a bound in `collect` + --> $RUST/core/src/iter/traits/iterator.rs + | + | Self: Sized, + | ^^^^^ required by this bound in `collect` error[E0277]: `()` is not an iterator --> tests/html_macro/iterable-fail.rs:18:19 diff --git a/packages/yew-macro/tests/html_macro/node-fail.stderr b/packages/yew-macro/tests/html_macro/node-fail.stderr index 5fb050c2ba1..16efc663380 100644 --- a/packages/yew-macro/tests/html_macro/node-fail.stderr +++ b/packages/yew-macro/tests/html_macro/node-fail.stderr @@ -51,6 +51,10 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: required because of the requirements on the impl of `ToString` for `()` = note: required because of the requirements on the impl of `From<()>` for `VNode` note: required by `from` + --> $RUST/core/src/convert/mod.rs + | + | fn from(_: T) -> Self; + | ^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/node-fail.rs:17:9 @@ -63,3 +67,7 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: required because of the requirements on the impl of `ToString` for `()` = note: required because of the requirements on the impl of `From<()>` for `VNode` note: required by `from` + --> $RUST/core/src/convert/mod.rs + | + | fn from(_: T) -> Self; + | ^^^^^^^^^^^^^^^^^^^^^^ From 8a255ae71982cc1e541b6cd9736f47a4af7c0c5c Mon Sep 17 00:00:00 2001 From: Anuvrat Date: Sat, 15 Jan 2022 23:38:04 +0530 Subject: [PATCH 3/4] Formats code using cargo fmt --- packages/yew/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/yew/src/lib.rs b/packages/yew/src/lib.rs index 619bfa6b759..7d4d7933749 100644 --- a/packages/yew/src/lib.rs +++ b/packages/yew/src/lib.rs @@ -376,7 +376,7 @@ where pub mod prelude { pub use crate::app_handle::AppHandle; pub use crate::callback::Callback; - pub use crate::context::{ContextProvider, ContextHandle}; + pub use crate::context::{ContextHandle, ContextProvider}; pub use crate::events::*; pub use crate::html::{ create_portal, BaseComponent, Children, ChildrenWithProps, Classes, Component, Context, From f8d06d42161a26512f70b5c1c7c3135e8bc61c1f Mon Sep 17 00:00:00 2001 From: Anuvrat Date: Tue, 25 Jan 2022 01:58:34 +0530 Subject: [PATCH 4/4] Revert "Adds ContextHandle in yew::prelude" This reverts commit abdf21f2d523ac2df56cca3d29f8860dbefc5cc5. --- .../yew-macro/tests/derive_props/fail.stderr | 16 --------------- .../tests/html_macro/block-fail.stderr | 8 -------- .../tests/html_macro/component-fail.stderr | 12 ----------- .../tests/html_macro/element-fail.stderr | 4 ---- .../tests/html_macro/iterable-fail.stderr | 20 ------------------- .../tests/html_macro/node-fail.stderr | 8 -------- 6 files changed, 68 deletions(-) diff --git a/packages/yew-macro/tests/derive_props/fail.stderr b/packages/yew-macro/tests/derive_props/fail.stderr index 79a4a902ca9..a56dbe6ccd0 100644 --- a/packages/yew-macro/tests/derive_props/fail.stderr +++ b/packages/yew-macro/tests/derive_props/fail.stderr @@ -51,10 +51,6 @@ error[E0277]: the trait bound `Value: Default` is not satisfied | ^^^^^^^^^^ the trait `Default` is not implemented for `Value` | note: required by `Option::::unwrap_or_default` - --> $RUST/core/src/option.rs - | - | pub fn unwrap_or_default(self) -> T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = 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` @@ -103,10 +99,6 @@ error[E0277]: expected a `FnOnce<()>` closure, found `{integer}` = help: the trait `FnOnce<()>` is not implemented for `{integer}` = note: wrap the `{integer}` in a closure with no arguments: `|| { /* code */ }` note: required by a bound in `Option::::unwrap_or_else` - --> $RUST/core/src/option.rs - | - | pub fn unwrap_or_else T>(self, f: F) -> T { - | ^ required by this bound in `Option::::unwrap_or_else` error[E0593]: function is expected to take 0 arguments, but it takes 1 argument --> tests/derive_props/fail.rs:97:24 @@ -118,10 +110,6 @@ error[E0593]: function is expected to take 0 arguments, but it takes 1 argument | -------------------------- takes 1 argument | note: required by a bound in `Option::::unwrap_or_else` - --> $RUST/core/src/option.rs - | - | pub fn unwrap_or_else T>(self, f: F) -> T { - | ^ required by this bound in `Option::::unwrap_or_else` error[E0271]: type mismatch resolving ` i32 {t10::foo} as FnOnce<()>>::Output == String` --> tests/derive_props/fail.rs:111:24 @@ -130,7 +118,3 @@ error[E0271]: type mismatch resolving ` i32 {t10::foo} as FnOnce<()>>::O | ^^^ expected struct `String`, found `i32` | note: required by `Option::::unwrap_or_else` - --> $RUST/core/src/option.rs - | - | pub fn unwrap_or_else T>(self, f: F) -> T { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/packages/yew-macro/tests/html_macro/block-fail.stderr b/packages/yew-macro/tests/html_macro/block-fail.stderr index fbf2c27503c..0f7099ee5b9 100644 --- a/packages/yew-macro/tests/html_macro/block-fail.stderr +++ b/packages/yew-macro/tests/html_macro/block-fail.stderr @@ -12,10 +12,6 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: 2 redundant requirements hidden = note: required because of the requirements on the impl of `Into>` for `()` note: required by `into` - --> $RUST/core/src/convert/mod.rs - | - | fn into(self) -> T; - | ^^^^^^^^^^^^^^^^^^^ error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/block-fail.rs:12:16 @@ -31,10 +27,6 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: 2 redundant requirements hidden = note: required because of the requirements on the impl of `Into>` for `()` note: required by `into` - --> $RUST/core/src/convert/mod.rs - | - | fn into(self) -> T; - | ^^^^^^^^^^^^^^^^^^^ error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/block-fail.rs:15:17 diff --git a/packages/yew-macro/tests/html_macro/component-fail.stderr b/packages/yew-macro/tests/html_macro/component-fail.stderr index 175a8776a93..3a0eb2af361 100644 --- a/packages/yew-macro/tests/html_macro/component-fail.stderr +++ b/packages/yew-macro/tests/html_macro/component-fail.stderr @@ -442,10 +442,6 @@ error[E0277]: the trait bound `VChild: From` is | = note: required because of the requirements on the impl of `Into>` for `yew::virtual_dom::VText` note: required by `into` - --> $RUST/core/src/convert/mod.rs - | - | fn into(self) -> T; - | ^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `VChild: From` is not satisfied --> tests/html_macro/component-fail.rs:102:29 @@ -455,10 +451,6 @@ error[E0277]: the trait bound `VChild: From` is not satisfied | = note: required because of the requirements on the impl of `Into>` for `VNode` note: required by `into` - --> $RUST/core/src/convert/mod.rs - | - | fn into(self) -> T; - | ^^^^^^^^^^^^^^^^^^^ error[E0277]: the trait bound `VChild: From` is not satisfied --> tests/html_macro/component-fail.rs:103:30 @@ -468,7 +460,3 @@ error[E0277]: the trait bound `VChild: From` is not satisfied | = note: required because of the requirements on the impl of `Into>` for `VNode` note: required by `into` - --> $RUST/core/src/convert/mod.rs - | - | fn into(self) -> T; - | ^^^^^^^^^^^^^^^^^^^ diff --git a/packages/yew-macro/tests/html_macro/element-fail.stderr b/packages/yew-macro/tests/html_macro/element-fail.stderr index 467cd3e84df..0ef61f0b6e5 100644 --- a/packages/yew-macro/tests/html_macro/element-fail.stderr +++ b/packages/yew-macro/tests/html_macro/element-fail.stderr @@ -486,7 +486,3 @@ error[E0277]: the trait bound `Cow<'static, str>: From<{integer}>` is not satisf and 14 others = note: required because of the requirements on the impl of `Into>` for `{integer}` note: required by `into` - --> $RUST/core/src/convert/mod.rs - | - | fn into(self) -> T; - | ^^^^^^^^^^^^^^^^^^^ diff --git a/packages/yew-macro/tests/html_macro/iterable-fail.stderr b/packages/yew-macro/tests/html_macro/iterable-fail.stderr index 21ed58c89c4..b1702551117 100644 --- a/packages/yew-macro/tests/html_macro/iterable-fail.stderr +++ b/packages/yew-macro/tests/html_macro/iterable-fail.stderr @@ -13,10 +13,6 @@ error[E0277]: `()` is not an iterator = help: the trait `Iterator` is not implemented for `()` = note: required because of the requirements on the impl of `IntoIterator` for `()` note: required by `into_iter` - --> $RUST/core/src/iter/traits/collect.rs - | - | fn into_iter(self) -> Self::IntoIter; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `()` is not an iterator --> tests/html_macro/iterable-fail.rs:6:17 @@ -27,10 +23,6 @@ error[E0277]: `()` is not an iterator = help: the trait `Iterator` is not implemented for `()` = note: required because of the requirements on the impl of `IntoIterator` for `()` note: required by `into_iter` - --> $RUST/core/src/iter/traits/collect.rs - | - | fn into_iter(self) -> Self::IntoIter; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/iterable-fail.rs:7:17 @@ -45,10 +37,6 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: required because of the requirements on the impl of `Into` for `()` = note: required because of the requirements on the impl of `FromIterator<()>` for `VNode` note: required by a bound in `collect` - --> $RUST/core/src/iter/traits/iterator.rs - | - | Self: Sized, - | ^^^^^ required by this bound in `collect` error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/iterable-fail.rs:10:17 @@ -63,10 +51,6 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: required because of the requirements on the impl of `Into` for `()` = note: required because of the requirements on the impl of `FromIterator<()>` for `VNode` note: required by a bound in `collect` - --> $RUST/core/src/iter/traits/iterator.rs - | - | Self: Sized, - | ^^^^^ required by this bound in `collect` error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/iterable-fail.rs:13:17 @@ -82,10 +66,6 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: required because of the requirements on the impl of `Into` for `&()` = note: required because of the requirements on the impl of `FromIterator<&()>` for `VNode` note: required by a bound in `collect` - --> $RUST/core/src/iter/traits/iterator.rs - | - | Self: Sized, - | ^^^^^ required by this bound in `collect` error[E0277]: `()` is not an iterator --> tests/html_macro/iterable-fail.rs:18:19 diff --git a/packages/yew-macro/tests/html_macro/node-fail.stderr b/packages/yew-macro/tests/html_macro/node-fail.stderr index 16efc663380..5fb050c2ba1 100644 --- a/packages/yew-macro/tests/html_macro/node-fail.stderr +++ b/packages/yew-macro/tests/html_macro/node-fail.stderr @@ -51,10 +51,6 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: required because of the requirements on the impl of `ToString` for `()` = note: required because of the requirements on the impl of `From<()>` for `VNode` note: required by `from` - --> $RUST/core/src/convert/mod.rs - | - | fn from(_: T) -> Self; - | ^^^^^^^^^^^^^^^^^^^^^^ error[E0277]: `()` doesn't implement `std::fmt::Display` --> tests/html_macro/node-fail.rs:17:9 @@ -67,7 +63,3 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` = note: required because of the requirements on the impl of `ToString` for `()` = note: required because of the requirements on the impl of `From<()>` for `VNode` note: required by `from` - --> $RUST/core/src/convert/mod.rs - | - | fn from(_: T) -> Self; - | ^^^^^^^^^^^^^^^^^^^^^^