aboutsummaryrefslogtreecommitdiff
path: root/macros/src/syntax/parse/hardware_task.rs
diff options
context:
space:
mode:
authorGravatar Emil Fresk <emil.fresk@gmail.com> 2023-01-10 21:03:10 +0100
committerGravatar Henrik Tjäder <henrik@tjaders.com> 2023-03-01 00:33:30 +0100
commitd6d58b0eb88242cf63724e1420bd29f8a4489916 (patch)
treed797b67b381947cc375d9c89cdc15d0cc98dee1a /macros/src/syntax/parse/hardware_task.rs
parentcd790a94286cdc307d399b7f7a43e305e90de5bf (diff)
downloadrtic-d6d58b0eb88242cf63724e1420bd29f8a4489916.tar.gz
rtic-d6d58b0eb88242cf63724e1420bd29f8a4489916.tar.zst
rtic-d6d58b0eb88242cf63724e1420bd29f8a4489916.zip
Async tasks can now take arguments at spawn again
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,
+ });
+ }
}
}