fix: Support Div () as component
previously I from some reason I thought this not allowed syntax. Some test failed because of my misunderstood, so now I fix this :D
This commit is contained in:
1 parent
03a14f4a86
commit
252f9343b8
2 files changed
+1
-17
No files matched your search
@@ -24,16 +24,6 @@ macro_rules! component_path_cannot_have_arguments {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
macro_rules! component_ident_cannot_use_paren {
|
|
||||||
($span:expr, $com_name:ident) => {
|
|
||||||
proc_macro_error::abort!(
|
|
||||||
$span,
|
|
||||||
"Invalid component syntax";
|
|
||||||
help = "try replace {} (..) to {} {{..}}", $com_name, $com_name;
|
|
||||||
)
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
macro_rules! invalid_component_path {
|
macro_rules! invalid_component_path {
|
||||||
($span:expr) => {
|
($span:expr) => {
|
||||||
proc_macro_error::abort!($span, "Invalid component path syntax")
|
proc_macro_error::abort!($span, "Invalid component path syntax")
|
||||||
|
|||||||
@@ -57,6 +57,7 @@ impl Parse for BodyNode {
|
|||||||
//
|
//
|
||||||
// example
|
// example
|
||||||
// Div {}
|
// Div {}
|
||||||
|
// Div ()
|
||||||
// ::Div {}
|
// ::Div {}
|
||||||
// crate::Div {}
|
// crate::Div {}
|
||||||
// component()
|
// component()
|
||||||
@@ -67,13 +68,6 @@ impl Parse for BodyNode {
|
|||||||
// Input::<InputProps<'_, i32> {}
|
// Input::<InputProps<'_, i32> {}
|
||||||
// crate::Input::<InputProps<'_, i32> {}
|
// crate::Input::<InputProps<'_, i32> {}
|
||||||
if body_stream.peek(token::Brace) || body_stream.peek(token::Paren) {
|
if body_stream.peek(token::Brace) || body_stream.peek(token::Paren) {
|
||||||
// NOTE: this syntax is not allowd:
|
|
||||||
// Div () -> comp
|
|
||||||
if path.segments.len() == 1 && body_stream.peek(token::Paren) {
|
|
||||||
let com_ident = &path.segments.iter().next().unwrap().ident;
|
|
||||||
component_ident_cannot_use_paren!(path, com_ident);
|
|
||||||
}
|
|
||||||
|
|
||||||
Component::validate_component_path(&path)?;
|
Component::validate_component_path(&path)?;
|
||||||
|
|
||||||
return Ok(BodyNode::Component(stream.parse()?));
|
return Ok(BodyNode::Component(stream.parse()?));
|
||||||
|
|||||||
Reference in new issue
Block a user