diff --git a/packages/yew-macro/src/props/prop.rs b/packages/yew-macro/src/props/prop.rs index 48f8e9eae77..82ae6375ff1 100644 --- a/packages/yew-macro/src/props/prop.rs +++ b/packages/yew-macro/src/props/prop.rs @@ -28,7 +28,7 @@ impl Parse for Prop { fn parse(input: ParseStream) -> syn::Result { let directive = input .parse::() - .map(|parsed| PropDirective::ApplyAsProperty(parsed)) + .map(PropDirective::ApplyAsProperty) .ok(); if input.peek(Brace) { Self::parse_shorthand_prop_assignment(input, directive) diff --git a/packages/yew-macro/tests/html_macro/component-fail.stderr b/packages/yew-macro/tests/html_macro/component-fail.stderr index fb02ae65600..1a756718b44 100644 --- a/packages/yew-macro/tests/html_macro/component-fail.stderr +++ b/packages/yew-macro/tests/html_macro/component-fail.stderr @@ -249,7 +249,13 @@ help: escape `type` to use it as an identifier 85 | html! { }; | ++ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Tuple( + ExprTuple { + attrs: [], + paren_token: Paren, + elems: [], + }, + ) --> tests/html_macro/component-fail.rs:86:24 | 86 | html! { }; @@ -309,7 +315,24 @@ error: only one root html element is allowed (hint: you can wrap multiple html e 102 | html! { }; | ^^^^^^^^^^^^^^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Path( + ExprPath { + attrs: [], + qself: None, + path: Path { + leading_colon: None, + segments: [ + PathSegment { + ident: Ident { + ident: "num", + span: #0 bytes(3894..3897), + }, + arguments: None, + }, + ], + }, + }, + ) --> tests/html_macro/component-fail.rs:106:24 | 106 | html! { }; diff --git a/packages/yew-macro/tests/html_macro/element-fail.stderr b/packages/yew-macro/tests/html_macro/element-fail.stderr index 089444ed8ba..08072df2e7f 100644 --- a/packages/yew-macro/tests/html_macro/element-fail.stderr +++ b/packages/yew-macro/tests/html_macro/element-fail.stderr @@ -142,61 +142,260 @@ error: dynamic closing tags must not have a body (hint: replace it with just ` }; | ^^^^^^^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Tuple( + ExprTuple { + attrs: [], + paren_token: Paren, + elems: [ + Lit( + ExprLit { + attrs: [], + lit: Str( + LitStr { + token: "deprecated", + }, + ), + }, + ), + Comma, + Lit( + ExprLit { + attrs: [], + lit: Str( + LitStr { + token: "warning", + }, + ), + }, + ), + ], + }, + ) --> tests/html_macro/element-fail.rs:83:24 | 83 | html! {
}; | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Tuple( + ExprTuple { + attrs: [], + paren_token: Paren, + elems: [], + }, + ) --> tests/html_macro/element-fail.rs:84:24 | 84 | html! { }; | ^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Tuple( + ExprTuple { + attrs: [], + paren_token: Paren, + elems: [], + }, + ) --> tests/html_macro/element-fail.rs:85:24 | 85 | html! { }; | ^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Call( + ExprCall { + attrs: [], + func: Path( + ExprPath { + attrs: [], + qself: None, + path: Path { + leading_colon: None, + segments: [ + PathSegment { + ident: Ident { + ident: "Some", + span: #0 bytes(2632..2636), + }, + arguments: None, + }, + ], + }, + }, + ), + paren_token: Paren, + args: [ + Lit( + ExprLit { + attrs: [], + lit: Int( + LitInt { + token: 5, + }, + ), + }, + ), + ], + }, + ) --> tests/html_macro/element-fail.rs:86:28 | 86 | html! { }; | ^^^^^^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Path( + ExprPath { + attrs: [], + qself: None, + path: Path { + leading_colon: None, + segments: [ + PathSegment { + ident: Ident { + ident: "NotToString", + span: #0 bytes(2672..2683), + }, + arguments: None, + }, + ], + }, + }, + ) --> tests/html_macro/element-fail.rs:87:27 | 87 | html! { }; | ^^^^^^^^^^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Call( + ExprCall { + attrs: [], + func: Path( + ExprPath { + attrs: [], + qself: None, + path: Path { + leading_colon: None, + segments: [ + PathSegment { + ident: Ident { + ident: "Some", + span: #0 bytes(2711..2715), + }, + arguments: None, + }, + ], + }, + }, + ), + paren_token: Paren, + args: [ + Path( + ExprPath { + attrs: [], + qself: None, + path: Path { + leading_colon: None, + segments: [ + PathSegment { + ident: Ident { + ident: "NotToString", + span: #0 bytes(2716..2727), + }, + arguments: None, + }, + ], + }, + }, + ), + ], + }, + ) --> tests/html_macro/element-fail.rs:88:22 | 88 | html! { }; | ^^^^^^^^^^^^^^^^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Call( + ExprCall { + attrs: [], + func: Path( + ExprPath { + attrs: [], + qself: None, + path: Path { + leading_colon: None, + segments: [ + PathSegment { + ident: Ident { + ident: "Some", + span: #0 bytes(2755..2759), + }, + arguments: None, + }, + ], + }, + }, + ), + paren_token: Paren, + args: [ + Lit( + ExprLit { + attrs: [], + lit: Int( + LitInt { + token: 5, + }, + ), + }, + ), + ], + }, + ) --> tests/html_macro/element-fail.rs:89:21 | 89 | html! { }; | ^^^^^^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Tuple( + ExprTuple { + attrs: [], + paren_token: Paren, + elems: [], + }, + ) --> tests/html_macro/element-fail.rs:90:25 | 90 | html! { }; | ^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Tuple( + ExprTuple { + attrs: [], + paren_token: Paren, + elems: [], + }, + ) --> tests/html_macro/element-fail.rs:91:26 | 91 | html! { }; | ^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: Path( + ExprPath { + attrs: [], + qself: None, + path: Path { + leading_colon: None, + segments: [ + PathSegment { + ident: Ident { + ident: "NotToString", + span: #0 bytes(2862..2873), + }, + arguments: None, + }, + ], + }, + }, + ) --> tests/html_macro/element-fail.rs:92:27 | 92 | html! { }; diff --git a/packages/yew-macro/tests/html_macro/list-fail.stderr b/packages/yew-macro/tests/html_macro/list-fail.stderr index 2c24fca6132..49cda7d753d 100644 --- a/packages/yew-macro/tests/html_macro/list-fail.stderr +++ b/packages/yew-macro/tests/html_macro/list-fail.stderr @@ -1,65 +1,87 @@ error: this opening fragment has no corresponding closing fragment - --> $DIR/list-fail.rs:5:13 + --> tests/html_macro/list-fail.rs:5:13 | 5 | html! { <> }; | ^^ error: this opening fragment has no corresponding closing fragment - --> $DIR/list-fail.rs:6:15 + --> tests/html_macro/list-fail.rs:6:15 | 6 | html! { <><> }; | ^^ error: this opening fragment has no corresponding closing fragment - --> $DIR/list-fail.rs:7:13 + --> tests/html_macro/list-fail.rs:7:13 | 7 | html! { <><> }; | ^^ error: this closing fragment has no corresponding opening fragment - --> $DIR/list-fail.rs:10:13 + --> tests/html_macro/list-fail.rs:10:13 | 10 | html! { }; | ^^^ error: this closing fragment has no corresponding opening fragment - --> $DIR/list-fail.rs:11:13 + --> tests/html_macro/list-fail.rs:11:13 | 11 | html! { }; | ^^^ error: only one root html element is allowed (hint: you can wrap multiple html elements in a fragment `<>`) - --> $DIR/list-fail.rs:14:18 + --> tests/html_macro/list-fail.rs:14:18 | 14 | html! { <><> }; | ^^^^^ error: expected a valid html element - --> $DIR/list-fail.rs:16:15 + --> tests/html_macro/list-fail.rs:16:15 | 16 | html! { <>invalid }; | ^^^^^^^ error: expected an expression following this equals sign - --> $DIR/list-fail.rs:18:17 + --> tests/html_macro/list-fail.rs:18:17 | 18 | html! { }; | ^^ -error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression. - --> $DIR/list-fail.rs:20:18 +error: the property value must be either a literal or enclosed in braces. Consider adding braces around your expression.: MethodCall( + ExprMethodCall { + attrs: [], + receiver: Lit( + ExprLit { + attrs: [], + lit: Str( + LitStr { + token: "key", + }, + ), + }, + ), + dot_token: Dot, + method: Ident { + ident: "to_string", + span: #0 bytes(404..413), + }, + turbofish: None, + paren_token: Paren, + args: [], + }, + ) + --> tests/html_macro/list-fail.rs:20:18 | 20 | html! { }; | ^^^^^^^^^^^^^^^^^ error: only a single `key` prop is allowed on a fragment - --> $DIR/list-fail.rs:23:30 + --> tests/html_macro/list-fail.rs:23:30 | 23 | html! { }; | ^^^ error: fragments only accept the `key` prop - --> $DIR/list-fail.rs:25:14 + --> tests/html_macro/list-fail.rs:25:14 | 25 | html! { }; | ^^^^^^^^^