Skip to content

Commit 9873225

Browse files
committed
Clarify entry signature and cs lifetime error in docs
1 parent a808059 commit 9873225

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

macros/src/lib.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,9 @@ use syn::{
9090
/// interrupts are enabled and possibly pass its return value into the entry function, allowing
9191
/// pre-interrupt initialization to be done.
9292
///
93+
/// Note that a function marked with the entry attribute is allowed to take no input parameters
94+
/// even if `init` returns a value, due to implementation details.
95+
///
9396
/// ## Examples
9497
///
9598
/// - Enable interrupts before entry
@@ -141,6 +144,12 @@ use syn::{
141144
/// loop {}
142145
/// }
143146
/// ```
147+
///
148+
/// ## Note
149+
///
150+
/// The `CriticalSection`s passed into the entry and the pre-interrupt functions have their
151+
/// lifetimes restrained to their respective functions. Attempting to pass the `CriticalSection`
152+
/// outside its scope fails with a `borrowed value does not live long enough` error.
144153
#[proc_macro_attribute]
145154
pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
146155
let interrupt_enable = if args.is_empty() {
@@ -394,6 +403,12 @@ impl EntryInterruptEnable {
394403
/// println!("{}", COUNT);
395404
/// }
396405
/// ```
406+
///
407+
/// ## Note
408+
///
409+
/// The `CriticalSection` passed into the interrupt function has its lifetime restrained to the
410+
/// function scope. Attempting to pass the `CriticalSection` outside its scope fails with a
411+
/// `borrowed value does not live long enough` error.
397412
#[proc_macro_attribute]
398413
pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
399414
let f: ItemFn = syn::parse(input).expect("`#[interrupt]` must be applied to a function");

src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@
208208
//!
209209
//! // expands into
210210
//!
211-
//! #[export_name = "main"]
212-
//! extern "C" fn randomly_generated_string() -> ! {
211+
//! #[no_mangle]
212+
//! extern "C" fn main() -> ! {
213213
//! /* user code */
214214
//! }
215215
//! ```

0 commit comments

Comments
 (0)