Mark VNode as #[must_use] (#3387)

This fixes for Rust Release 1.72.
Rust 1.72 makes `From::from` a must use, which effectively makes `html!` a must use.

I have tried various ways to suppress `unused_must_use` for `html!`.
However, it is not effective. So I added `let _ = ` to tests.

I have also made `VNode` a `#[must_use]` so the diagnostic will be easier to understand.

---

* Fix clippy.

* Make html must use.
This commit is contained in:
Kaede Hoshikawa 2023-08-29 00:01:07 +09:00 committed by GitHub
parent 3c4ac56980
commit 7ef8e0da18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 6 additions and 5 deletions

View File

@ -15,7 +15,7 @@ fn html_macro() {
element which can't have any children."
)]
fn dynamic_tags_catch_void_elements() {
html! {
let _ = html! {
<@{"br"}>
<span>{ "No children allowed" }</span>
</@>
@ -25,7 +25,7 @@ fn dynamic_tags_catch_void_elements() {
#[test]
#[should_panic(expected = "a dynamic tag returned a tag name containing non ASCII characters: `❤`")]
fn dynamic_tags_catch_non_ascii() {
html! {
let _ = html! {
<@{""}/>
};
}

View File

@ -156,11 +156,11 @@ mod test {
#[test]
fn text_as_root() {
html! {
let _ = html! {
"Text Node As Root"
};
html! {
let _ = html! {
{ "Text Node As Root" }
};
}

View File

@ -82,7 +82,7 @@ mod test {
#[test]
fn all_key_conversions() {
html! {
let _ = html! {
<key="string literal">
<img key={"String".to_owned()} />
<p key={Rc::<str>::from("rc")}></p>

View File

@ -13,6 +13,7 @@ use crate::AttrValue;
/// Bind virtual element to a DOM reference.
#[derive(Clone, PartialEq)]
#[must_use = "html does not do anything unless returned to Yew for rendering."]
pub enum VNode {
/// A bind between `VTag` and `Element`.
VTag(Box<VTag>),