Skip to content

Commit 4e70f06

Browse files
committed
yew-macro/html_element: fix error span regression
1 parent 7478a77 commit 4e70f06

File tree

2 files changed

+15
-14
lines changed

2 files changed

+15
-14
lines changed

packages/yew-macro/src/html_tree/html_element.rs

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -221,12 +221,20 @@ impl ToTokens for HtmlElement {
221221
quote! { ::std::vec![#(#listeners_it),*].into_iter().flatten().collect() }
222222
};
223223

224+
let child_list = quote! {
225+
::yew::virtual_dom::VList{
226+
key: ::std::option::Option::None,
227+
children: #children,
228+
}
229+
};
230+
224231
tokens.extend(match &name {
225232
TagName::Lit(name) => {
233+
let name_span = name.span();
226234
let name = name.to_ascii_lowercase_string();
227235
match &*name {
228236
"input" => {
229-
quote_spanned! {name.span()=>
237+
quote_spanned! {name_span=>
230238
#[allow(clippy::redundant_clone, unused_braces)]
231239
::std::convert::Into::<::yew::virtual_dom::VNode>::into(
232240
::yew::virtual_dom::VTag::__new_input(
@@ -241,7 +249,7 @@ impl ToTokens for HtmlElement {
241249
}
242250
}
243251
"textarea" => {
244-
quote_spanned! {name.span()=>
252+
quote_spanned! {name_span=>
245253
#[allow(clippy::redundant_clone, unused_braces)]
246254
::std::convert::Into::<::yew::virtual_dom::VNode>::into(
247255
::yew::virtual_dom::VTag::__new_textarea(
@@ -255,7 +263,7 @@ impl ToTokens for HtmlElement {
255263
}
256264
}
257265
_ => {
258-
quote_spanned! {name.span()=>
266+
quote_spanned! {name_span=>
259267
#[allow(clippy::redundant_clone, unused_braces)]
260268
::std::convert::Into::<::yew::virtual_dom::VNode>::into(
261269
::yew::virtual_dom::VTag::__new_other(
@@ -264,10 +272,7 @@ impl ToTokens for HtmlElement {
264272
#key,
265273
#attributes,
266274
#listeners,
267-
::yew::virtual_dom::VList{
268-
key: ::std::option::Option::None,
269-
children: #children,
270-
},
275+
#child_list,
271276
),
272277
)
273278
}
@@ -332,10 +337,7 @@ impl ToTokens for HtmlElement {
332337
#key,
333338
#attributes,
334339
#listeners,
335-
::yew::virtual_dom::VList{
336-
key: ::std::option::Option::None,
337-
children: #children,
338-
},
340+
#child_list,
339341
);
340342

341343
#handle_value_attr

packages/yew-macro/tests/html_macro/component-fail.stderr

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,11 +314,10 @@ error[E0277]: the trait bound `VChild<Child>: From<VNode>` is not satisfied
314314
= note: required by `into`
315315

316316
error[E0277]: the trait bound `VChild<Child>: From<VNode>` is not satisfied
317-
--> $DIR/component-fail.rs:100:5
317+
--> $DIR/component-fail.rs:100:30
318318
|
319319
100 | html! { <ChildContainer><other /></ChildContainer> };
320-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `From<VNode>` is not implemented for `VChild<Child>`
320+
| ^^^^^ the trait `From<VNode>` is not implemented for `VChild<Child>`
321321
|
322322
= note: required because of the requirements on the impl of `Into<VChild<Child>>` for `VNode`
323323
= note: required by `into`
324-
= note: this error originates in a macro (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)