aboutsummaryrefslogtreecommitdiff
path: root/rtic-macros/src/syntax/parse/software_task.rs
diff options
context:
space:
mode:
Diffstat (limited to 'rtic-macros/src/syntax/parse/software_task.rs')
-rw-r--r--rtic-macros/src/syntax/parse/software_task.rs13
1 files changed, 9 insertions, 4 deletions
diff --git a/rtic-macros/src/syntax/parse/software_task.rs b/rtic-macros/src/syntax/parse/software_task.rs
index 769aa65..175769c 100644
--- a/rtic-macros/src/syntax/parse/software_task.rs
+++ b/rtic-macros/src/syntax/parse/software_task.rs
@@ -8,8 +8,9 @@ use crate::syntax::{
impl SoftwareTask {
pub(crate) fn parse(args: SoftwareTaskArgs, item: ItemFn) -> parse::Result<Self> {
+ let is_bottom = util::type_is_bottom(&item.sig.output);
let valid_signature = util::check_fn_signature(&item, true)
- && util::type_is_unit(&item.sig.output)
+ && (util::type_is_unit(&item.sig.output) || is_bottom)
&& item.sig.asyncness.is_some();
let span = item.sig.ident.span();
@@ -28,13 +29,14 @@ impl SoftwareTask {
inputs,
stmts: item.block.stmts,
is_extern: false,
+ is_bottom,
});
}
}
Err(parse::Error::new(
span,
- format!("this task handler must have type signature `async fn({name}::Context, ..)`"),
+ format!("this task handler must have type signature `async fn({name}::Context, ..)` or `async fn({name}::Context, ..) -> !`"),
))
}
}
@@ -44,8 +46,10 @@ impl SoftwareTask {
args: SoftwareTaskArgs,
item: ForeignItemFn,
) -> parse::Result<Self> {
+ let is_bottom = util::type_is_bottom(&item.sig.output);
+
let valid_signature = util::check_foreign_fn_signature(&item, true)
- && util::type_is_unit(&item.sig.output)
+ && (util::type_is_unit(&item.sig.output) || is_bottom)
&& item.sig.asyncness.is_some();
let span = item.sig.ident.span();
@@ -64,13 +68,14 @@ impl SoftwareTask {
inputs,
stmts: Vec::<Stmt>::new(),
is_extern: true,
+ is_bottom,
});
}
}
Err(parse::Error::new(
span,
- format!("this task handler must have type signature `async fn({name}::Context, ..)`"),
+ format!("this task handler must have type signature `async fn({name}::Context, ..)` or `async fn({name}::Context, ..) -> !`"),
))
}
}