mirror of
https://github.com/yewstack/yew.git
synced 2025-12-08 21:26:25 +00:00
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:
parent
3c4ac56980
commit
7ef8e0da18
@ -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! {
|
||||
<@{"❤"}/>
|
||||
};
|
||||
}
|
||||
|
||||
@ -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" }
|
||||
};
|
||||
}
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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>),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user