Improve misplaced block error message.

This commit is contained in:
Bodil Stokke 2018-11-29 16:08:59 +00:00
parent e80c8e6d88
commit 1823e5ecb9
1 changed files with 7 additions and 1 deletions

View File

@ -25,7 +25,13 @@ impl Node {
let text = TokenTree::Literal(text); let text = TokenTree::Literal(text);
Ok(quote!(Box::new(typed_html::dom::TextNode::new(#text.to_string())))) Ok(quote!(Box::new(typed_html::dom::TextNode::new(#text.to_string()))))
} }
Node::Block(_) => panic!("cannot have a block in this position"), Node::Block(group) => {
let span = group.span();
let error = "you cannot use a block as a top level element or a required child element";
Err(quote_spanned!{ span=>
compile_error! { #error }
})
}
} }
} }