aboutsummaryrefslogtreecommitdiff
path: root/macros/src/syntax/parse/hardware_task.rs
diff options
context:
space:
mode:
Diffstat (limited to 'macros/src/syntax/parse/hardware_task.rs')
-rw-r--r--macros/src/syntax/parse/hardware_task.rs58
1 files changed, 24 insertions, 34 deletions
diff --git a/macros/src/syntax/parse/hardware_task.rs b/macros/src/syntax/parse/hardware_task.rs
index c13426f4..7f6dfbe4 100644
--- a/macros/src/syntax/parse/hardware_task.rs
+++ b/macros/src/syntax/parse/hardware_task.rs
@@ -15,25 +15,20 @@ impl HardwareTask {
let name = item.sig.ident.to_string();
- if name == "init" || name == "idle" {
- return Err(parse::Error::new(
- span,
- "tasks cannot be named `init` or `idle`",
- ));
- }
-
if valid_signature {
- if let Some(context) = util::parse_inputs(item.sig.inputs, &name) {
- let FilterAttrs { cfgs, attrs, .. } = util::filter_attributes(item.attrs);
+ if let Some((context, Ok(rest))) = util::parse_inputs(item.sig.inputs, &name) {
+ if rest.is_empty() {
+ let FilterAttrs { cfgs, attrs, .. } = util::filter_attributes(item.attrs);
- return Ok(HardwareTask {
- args,
- cfgs,
- attrs,
- context,
- stmts: item.block.stmts,
- is_extern: false,
- });
+ return Ok(HardwareTask {
+ args,
+ cfgs,
+ attrs,
+ context,
+ stmts: item.block.stmts,
+ is_extern: false,
+ });
+ }
}
}
@@ -56,25 +51,20 @@ impl HardwareTask {
let name = item.sig.ident.to_string();
- if name == "init" || name == "idle" {
- return Err(parse::Error::new(
- span,
- "tasks cannot be named `init` or `idle`",
- ));
- }
-
if valid_signature {
- if let Some(context) = util::parse_inputs(item.sig.inputs, &name) {
- let FilterAttrs { cfgs, attrs, .. } = util::filter_attributes(item.attrs);
+ if let Some((context, Ok(rest))) = util::parse_inputs(item.sig.inputs, &name) {
+ if rest.is_empty() {
+ let FilterAttrs { cfgs, attrs, .. } = util::filter_attributes(item.attrs);
- return Ok(HardwareTask {
- args,
- cfgs,
- attrs,
- context,
- stmts: Vec::<Stmt>::new(),
- is_extern: true,
- });
+ return Ok(HardwareTask {
+ args,
+ cfgs,
+ attrs,
+ context,
+ stmts: Vec::<Stmt>::new(),
+ is_extern: true,
+ });
+ }
}
}