Skip to content
This repository was archived by the owner on Jan 24, 2022. It is now read-only.

Commit 5411528

Browse files
bors[bot]sjroe
andcommitted
Merge #78
78: Modified the entry and exception macros to accept a closure. r=japaric a=sjroe This allows: ```rust entry!(|| { let mut x = 1; loop { x = x + 1; } }); ``` as well as allowing the original usage: ```rust entry!(main); fn main() -> ! { let mut x = 1; loop { x = x + 1; } } ``` The same is true for exceptions: ```rust exception!(*, |irqn: i16| { panic!("Unhandled exception (IRQn = {})", irqn); }); ``` Co-authored-by: Stephen Roe <[email protected]>
2 parents bf87aae + ef68e88 commit 5411528

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/lib.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ pub unsafe extern "C" fn Reset() -> ! {
525525
/// The signature of the specified function must be `fn() -> !` (never ending function)
526526
#[macro_export]
527527
macro_rules! entry {
528-
($path:path) => {
528+
($path:expr) => {
529529
#[export_name = "main"]
530530
pub extern "C" fn __impl_main() -> ! {
531531
// validate the signature of the program entry point
@@ -695,7 +695,7 @@ pub static __INTERRUPTS: [unsafe extern "C" fn(); 32] = [{
695695
/// $Name:ident,
696696
///
697697
/// // Path to the exception handler (a function)
698-
/// $handler:path,
698+
/// $handler:expr,
699699
///
700700
/// // Optional, state preserved across invocations of the handler
701701
/// state: $State:ty = $initial_state:expr,
@@ -790,7 +790,7 @@ pub static __INTERRUPTS: [unsafe extern "C" fn(); 32] = [{
790790
/// ```
791791
#[macro_export]
792792
macro_rules! exception {
793-
(* , $handler:path) => {
793+
(* , $handler:expr) => {
794794
#[allow(unsafe_code)]
795795
#[deny(private_no_mangle_fns)] // raise an error if this item is not accessible
796796
#[no_mangle]
@@ -808,7 +808,7 @@ macro_rules! exception {
808808
}
809809
};
810810

811-
(HardFault, $handler:path) => {
811+
(HardFault, $handler:expr) => {
812812
#[allow(unsafe_code)]
813813
#[deny(private_no_mangle_fns)] // raise an error if this item is not accessible
814814
#[no_mangle]
@@ -820,7 +820,7 @@ macro_rules! exception {
820820
}
821821
};
822822

823-
($Name:ident, $handler:path,state: $State:ty = $initial_state:expr) => {
823+
($Name:ident, $handler:expr,state: $State:ty = $initial_state:expr) => {
824824
#[allow(unsafe_code)]
825825
#[deny(private_no_mangle_fns)] // raise an error if this item is not accessible
826826
#[no_mangle]
@@ -837,7 +837,7 @@ macro_rules! exception {
837837
}
838838
};
839839

840-
($Name:ident, $handler:path) => {
840+
($Name:ident, $handler:expr) => {
841841
#[allow(unsafe_code)]
842842
#[deny(private_no_mangle_fns)] // raise an error if this item is not accessible
843843
#[no_mangle]

0 commit comments

Comments
 (0)