Skip to content

Commit 7eaa5c5

Browse files
authored
Merge pull request #19 from YuhanLiin/inline-interrupt
Inline interrupt inner functions
2 parents 647877a + 0ce415d commit 7eaa5c5

File tree

4 files changed

+88
-1
lines changed

4 files changed

+88
-1
lines changed

macros/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,8 @@ use syn::{
9191
/// pre-interrupt initialization to be done.
9292
///
9393
/// 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.
94+
/// even if `init` returns a value, due to implementation details. To reduce code size, it is
95+
/// strongly recommended to put `#[inline(always)]` on `init` if it's used nowhere else.
9596
///
9697
/// ## Examples
9798
///
@@ -115,6 +116,7 @@ use syn::{
115116
/// use msp430::interrupt::CriticalSection;
116117
///
117118
/// # struct Hal;
119+
/// #[inline(always)]
118120
/// fn init(cs: CriticalSection) -> Hal {
119121
/// /* initialize hardware */
120122
/// # Hal
@@ -135,6 +137,7 @@ use syn::{
135137
/// # use msp430_rt_macros::entry;
136138
/// use msp430::interrupt::CriticalSection;
137139
///
140+
/// #[inline(always)]
138141
/// fn arg(cs: CriticalSection) {
139142
/// /* initialize */
140143
/// }
@@ -494,6 +497,7 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
494497
#unsafety extern "msp430-interrupt" fn #hash() {
495498
#check
496499

500+
#[inline(always)]
497501
#unsafety fn #hash<'a>(#fn_param) #output {
498502
#(#vars)*
499503
#(#stmts)*
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
error[E0433]: failed to resolve: use of undeclared crate or module `interrupt`
2+
--> tests/ui/interrupt_wrong_import.rs:11:1
3+
|
4+
11 | #[interrupt]
5+
| ^^^^^^^^^^^^ use of undeclared crate or module `interrupt`
6+
|
7+
= note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info)
8+
9+
error[E0658]: msp430-interrupt ABI is experimental and subject to change
10+
--> tests/ui/interrupt_wrong_import.rs:11:1
11+
|
12+
11 | #[interrupt]
13+
| ^^^^^^^^^^^^
14+
|
15+
= note: see issue #38487 <https://github.com/rust-lang/rust/issues/38487> for more information
16+
= help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable
17+
= note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info)
18+
19+
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
20+
--> tests/ui/interrupt_wrong_import.rs:11:1
21+
|
22+
11 | #[interrupt]
23+
| ^^^^^^^^^^^^
24+
|
25+
= note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info)

macros/tests/ui/recursion.stderr

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error[E0425]: cannot find function `main` in this scope
2+
--> tests/ui/recursion.rs:7:5
3+
|
4+
7 | main(cs)
5+
| ^^^^ not found in this scope
6+
7+
error[E0425]: cannot find function, tuple struct or tuple variant `DefaultHandler` in this scope
8+
--> tests/ui/recursion.rs:12:5
9+
|
10+
12 | DefaultHandler(cs)
11+
| ^^^^^^^^^^^^^^ not found in this scope
12+
13+
error[E0658]: msp430-interrupt ABI is experimental and subject to change
14+
--> tests/ui/recursion.rs:10:1
15+
|
16+
10 | #[interrupt]
17+
| ^^^^^^^^^^^^
18+
|
19+
= note: see issue #38487 <https://github.com/rust-lang/rust/issues/38487> for more information
20+
= help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable
21+
= note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info)
22+
23+
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
24+
--> tests/ui/recursion.rs:10:1
25+
|
26+
10 | #[interrupt]
27+
| ^^^^^^^^^^^^
28+
|
29+
= note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info)

macros/tests/ui/recursion2.stderr

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
error[E0425]: cannot find function `main` in this scope
2+
--> tests/ui/recursion2.rs:7:5
3+
|
4+
7 | main()
5+
| ^^^^ not found in this scope
6+
7+
error[E0425]: cannot find function, tuple struct or tuple variant `DefaultHandler` in this scope
8+
--> tests/ui/recursion2.rs:12:5
9+
|
10+
12 | DefaultHandler()
11+
| ^^^^^^^^^^^^^^ not found in this scope
12+
13+
error[E0658]: msp430-interrupt ABI is experimental and subject to change
14+
--> tests/ui/recursion2.rs:10:1
15+
|
16+
10 | #[interrupt]
17+
| ^^^^^^^^^^^^
18+
|
19+
= note: see issue #38487 <https://github.com/rust-lang/rust/issues/38487> for more information
20+
= help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable
21+
= note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info)
22+
23+
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
24+
--> tests/ui/recursion2.rs:10:1
25+
|
26+
10 | #[interrupt]
27+
| ^^^^^^^^^^^^
28+
|
29+
= note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info)

0 commit comments

Comments
 (0)