Skip to content

Commit a0a1786

Browse files
Add a test that enables ALL the warnings
1 parent 36b33b2 commit a0a1786

File tree

2 files changed

+54
-0
lines changed

2 files changed

+54
-0
lines changed

cortex-m-rt/Cargo.toml

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ compiletest_rs = "0.4.0"
3131
name = "device"
3232
required-features = ["device"]
3333

34+
[[example]]
35+
name = "warnings"
36+
required-features = ["device"]
37+
3438
[[test]]
3539
name = "compiletest"
3640
required-features = ["device"]

cortex-m-rt/examples/warnings.rs

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
//! Tests that a crate can still build with all warnings enabled.
2+
//!
3+
//! The code generated by the `cortex-m-rt` macros might need to manually
4+
//! `#[allow]` some of them (even though Rust does that by default for a few
5+
//! warnings too).
6+
7+
#![no_std]
8+
#![no_main]
9+
#![deny(warnings, missing_docs, rust_2018_idioms)]
10+
11+
extern crate cortex_m_rt;
12+
extern crate panic_halt;
13+
14+
use cortex_m_rt::{entry, exception, interrupt, pre_init, ExceptionFrame};
15+
16+
#[allow(non_camel_case_types)]
17+
enum interrupt {
18+
INT,
19+
}
20+
21+
extern "C" {
22+
fn INT();
23+
}
24+
25+
union Vector {
26+
#[allow(dead_code)]
27+
handler: unsafe extern "C" fn(),
28+
}
29+
30+
#[link_section = ".vector_table.interrupts"]
31+
#[no_mangle]
32+
#[used]
33+
static __INTERRUPTS: [Vector; 1] = [Vector { handler: INT }];
34+
35+
/// Dummy interrupt.
36+
#[interrupt]
37+
fn INT() {}
38+
39+
#[exception]
40+
fn HardFault(_eh: &ExceptionFrame) -> ! {
41+
loop {}
42+
}
43+
44+
#[entry]
45+
fn main() -> ! {
46+
loop {}
47+
}
48+
49+
#[pre_init]
50+
unsafe fn pre_init() {}

0 commit comments

Comments
 (0)