Skip to content

Commit 685b417

Browse files
committed
Add trybuild tests
1 parent 135aa14 commit 685b417

8 files changed

+129
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![no_main]
2+
3+
use msp430::interrupt::CriticalSection;
4+
use msp430_rt_macros::entry;
5+
6+
fn init(cs: CriticalSection) -> u32 {
7+
32
8+
}
9+
10+
#[entry(interrupt_enable(pre_interrupt = init))]
11+
fn main(_i: bool) -> ! {
12+
loop {}
13+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
error[E0308]: mismatched types
2+
--> tests/ui/entry_preinterrupt_mismatch.rs:10:1
3+
|
4+
10 | #[entry(interrupt_enable(pre_interrupt = init))]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `bool`, found `u32`
6+
|
7+
= note: this error originates in the attribute macro `entry` (in Nightly builds, run with -Z macro-backtrace for more info)
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#![no_main]
2+
3+
use msp430_rt_macros::entry;
4+
5+
fn init() {}
6+
7+
#[entry(interrupt_enable(pre_interrupt = init))]
8+
fn main() -> ! {
9+
loop {}
10+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
error[E0061]: this function takes 0 arguments but 1 argument was supplied
2+
--> tests/ui/entry_preinterrupt_no_arg.rs:7:42
3+
|
4+
7 | #[entry(interrupt_enable(pre_interrupt = init))]
5+
| -----------------------------------------^^^^---
6+
| | |
7+
| | expected 0 arguments
8+
| supplied 1 argument
9+
|
10+
note: function defined here
11+
--> tests/ui/entry_preinterrupt_no_arg.rs:5:4
12+
|
13+
5 | fn init() {}
14+
| ^^^^
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#![no_main]
2+
3+
use msp430::interrupt::CriticalSection;
4+
use msp430_rt_macros::entry;
5+
6+
fn init<'a>(cs: CriticalSection<'a>) -> CriticalSection<'a> {
7+
cs
8+
}
9+
10+
#[entry(interrupt_enable(pre_interrupt = init))]
11+
fn main() -> ! {
12+
loop {}
13+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
error[E0597]: `cs` does not live long enough
2+
--> tests/ui/entry_preinterrupt_return_cs3.rs:10:1
3+
|
4+
10 | #[entry(interrupt_enable(pre_interrupt = init))]
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-
6+
| | |
7+
| | `cs` dropped here while still borrowed
8+
| borrowed value does not live long enough
9+
| borrow later stored here
10+
|
11+
= note: this error originates in the attribute macro `entry` (in Nightly builds, run with -Z macro-backtrace for more info)

macros/tests/ui/global_cs.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#![no_main]
2+
3+
use msp430::interrupt::CriticalSection;
4+
use msp430_rt_macros::{entry, interrupt};
5+
6+
static mut CS: Option<CriticalSection> = None;
7+
8+
#[entry]
9+
fn main(cs: CriticalSection) -> ! {
10+
unsafe {
11+
CS = Some(cs);
12+
}
13+
loop {}
14+
}
15+
16+
#[interrupt]
17+
fn DefaultHandler(cs: CriticalSection) -> ! {
18+
unsafe {
19+
CS = Some(cs);
20+
}
21+
loop {}
22+
}

macros/tests/ui/global_cs.stderr

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
error[E0658]: msp430-interrupt ABI is experimental and subject to change
2+
--> tests/ui/global_cs.rs:16:1
3+
|
4+
16 | #[interrupt]
5+
| ^^^^^^^^^^^^
6+
|
7+
= note: see issue #38487 <https://github.com/rust-lang/rust/issues/38487> for more information
8+
= help: add `#![feature(abi_msp430_interrupt)]` to the crate attributes to enable
9+
= note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info)
10+
11+
error[E0759]: `cs` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
12+
--> tests/ui/global_cs.rs:11:14
13+
|
14+
8 | #[entry]
15+
| -------- this data with lifetime `'a`...
16+
...
17+
11 | CS = Some(cs);
18+
| ^^^^^--^
19+
| |
20+
| ...is used and required to live as long as `'static` here
21+
22+
error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target
23+
--> tests/ui/global_cs.rs:16:1
24+
|
25+
16 | #[interrupt]
26+
| ^^^^^^^^^^^^
27+
|
28+
= note: this error originates in the attribute macro `interrupt` (in Nightly builds, run with -Z macro-backtrace for more info)
29+
30+
error[E0759]: `cs` has lifetime `'a` but it needs to satisfy a `'static` lifetime requirement
31+
--> tests/ui/global_cs.rs:19:14
32+
|
33+
16 | #[interrupt]
34+
| ------------ this data with lifetime `'a`...
35+
...
36+
19 | CS = Some(cs);
37+
| ^^^^^--^
38+
| |
39+
| ...is used and required to live as long as `'static` here

0 commit comments

Comments
 (0)