future-proof-iot / RIOT-rs

RIOT-rs is an operating system for secure, memory-safe, low-power Internet of Things, written in Rust
Apache License 2.0
32 stars 12 forks source link

macros: `task` macro errors if there are no parameters #352

Closed elenaf9 closed 1 week ago

elenaf9 commented 1 week ago

Summary

If I understand correctly, using the task macro without any parameters should be valid code:

// Manually started task that doesn't require any peripherals or hooks.
#[riot_rs::task] 
fn my_task() {
...
}

The macro currently doesn't allow this.

Relevant log output

error: unexpected end of input, expected an expression
  --> examples/threading-embassy/src/main.rs:12:1
   |
12 | #[riot_rs::task]
   | ^^^^^^^^^^^^^^^^
   |
   = note: this error originates in the attribute macro `riot_rs::embassy::embassy_executor::task` (in Nightly builds, run with -Z macro-backtrace for more info)

Hardware/ Setup

No response

Possible Solution

No response

Would you like to work on fixing this bug?

No

ROMemories commented 1 week ago

Good catch! The issue was related to code generation in that macro, and basically required that the pool_size parameter be provided when the autostart parameter wasn't, which is not the behavior we want. #353 should fix this.