aboutsummaryrefslogtreecommitdiff
path: root/macros/src/syntax/parse/software_task.rs
diff options
context:
space:
mode:
Diffstat (limited to 'macros/src/syntax/parse/software_task.rs')
-rw-r--r--macros/src/syntax/parse/software_task.rs26
1 files changed, 10 insertions, 16 deletions
diff --git a/macros/src/syntax/parse/software_task.rs b/macros/src/syntax/parse/software_task.rs
index 2b1ac4a5..6be597e8 100644
--- a/macros/src/syntax/parse/software_task.rs
+++ b/macros/src/syntax/parse/software_task.rs
@@ -8,17 +8,16 @@ use crate::syntax::{
impl SoftwareTask {
pub(crate) fn parse(args: SoftwareTaskArgs, item: ItemFn) -> parse::Result<Self> {
- let valid_signature =
- util::check_fn_signature(&item, true) && util::type_is_unit(&item.sig.output);
+ let valid_signature = util::check_fn_signature(&item, true)
+ && util::type_is_unit(&item.sig.output)
+ && item.sig.asyncness.is_some();
let span = item.sig.ident.span();
let name = item.sig.ident.to_string();
- let is_async = item.sig.asyncness.is_some();
-
if valid_signature {
- if let Some((context, Ok(inputs))) = util::parse_inputs(item.sig.inputs, &name) {
+ if let Some(context) = util::parse_inputs(item.sig.inputs, &name) {
let FilterAttrs { cfgs, attrs, .. } = util::filter_attributes(item.attrs);
return Ok(SoftwareTask {
@@ -26,10 +25,8 @@ impl SoftwareTask {
attrs,
cfgs,
context,
- inputs,
stmts: item.block.stmts,
is_extern: false,
- is_async,
});
}
}
@@ -37,7 +34,7 @@ impl SoftwareTask {
Err(parse::Error::new(
span,
&format!(
- "this task handler must have type signature `(async) fn({}::Context, ..)`",
+ "this task handler must have type signature `async fn({}::Context)`",
name
),
))
@@ -49,17 +46,16 @@ impl SoftwareTask {
args: SoftwareTaskArgs,
item: ForeignItemFn,
) -> parse::Result<Self> {
- let valid_signature =
- util::check_foreign_fn_signature(&item, true) && util::type_is_unit(&item.sig.output);
+ let valid_signature = util::check_foreign_fn_signature(&item, true)
+ && util::type_is_unit(&item.sig.output)
+ && item.sig.asyncness.is_some();
let span = item.sig.ident.span();
let name = item.sig.ident.to_string();
- let is_async = item.sig.asyncness.is_some();
-
if valid_signature {
- if let Some((context, Ok(inputs))) = util::parse_inputs(item.sig.inputs, &name) {
+ if let Some(context) = util::parse_inputs(item.sig.inputs, &name) {
let FilterAttrs { cfgs, attrs, .. } = util::filter_attributes(item.attrs);
return Ok(SoftwareTask {
@@ -67,10 +63,8 @@ impl SoftwareTask {
attrs,
cfgs,
context,
- inputs,
stmts: Vec::<Stmt>::new(),
is_extern: true,
- is_async,
});
}
}
@@ -78,7 +72,7 @@ impl SoftwareTask {
Err(parse::Error::new(
span,
&format!(
- "this task handler must have type signature `(async) fn({}::Context, ..)`",
+ "this task handler must have type signature `async fn({}::Context)`",
name
),
))