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

Commit 17ea2ee

Browse files
bors[bot]korken89jonas-schievink
authored
Merge #242
242: Backport lint fixes and test to 0.6.x r=adamgreig a=jonas-schievink Closes #240 Co-authored-by: Emil Fresk <[email protected]> Co-authored-by: Jonas Schievink <[email protected]>
2 parents 5b4ece5 + 00d300b commit 17ea2ee

File tree

7 files changed

+76
-6
lines changed

7 files changed

+76
-6
lines changed

CHANGELOG.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
## [v0.6.12] - 2020-01-26
11+
12+
### Fixed
13+
14+
- Fixed lint warnings getting emitted on macro-generated code.
15+
16+
## [v0.6.11] - 2019-12-04
17+
1018
### Changed
1119

1220
- Macros now generate a second trampoline function instead of randomizing the
@@ -466,7 +474,9 @@ section size addr
466474

467475
Initial release
468476

469-
[Unreleased]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.10...HEAD
477+
[Unreleased]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.12...HEAD
478+
[v0.6.12]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.11...v0.6.12
479+
[v0.6.11]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.10...v0.6.11
470480
[v0.6.10]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.9...v0.6.10
471481
[v0.6.9]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.8...v0.6.9
472482
[v0.6.8]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.7...v0.6.8

Cargo.toml

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ license = "MIT OR Apache-2.0"
1212
name = "cortex-m-rt"
1313
readme = "README.md"
1414
repository = "https://github.com/rust-embedded/cortex-m-rt"
15-
version = "0.6.11"
15+
version = "0.6.12"
1616
autoexamples = true
1717

1818
[dependencies]
1919
r0 = "0.2.2"
20-
cortex-m-rt-macros = { path = "macros", version = "0.1" }
20+
cortex-m-rt-macros = { path = "macros", version = "=0.1.8" }
2121

2222
[dev-dependencies]
2323
cortex-m = "0.6"
@@ -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"]

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() {}

macros/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ keywords = ["arm", "cortex-m", "runtime", "startup"]
77
license = "MIT OR Apache-2.0"
88
name = "cortex-m-rt-macros"
99
repository = "https://github.com/japaric/cortex-m-rt"
10-
version = "0.1.7"
10+
version = "0.1.8"
1111
edition = "2018"
1212

1313
[lib]

macros/src/lib.rs

+6
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream {
151151
.collect::<Vec<_>>();
152152

153153
quote!(
154+
#[doc(hidden)]
154155
#[export_name = "main"]
155156
pub unsafe extern "C" fn #tramp_ident() {
156157
#ident(
@@ -343,6 +344,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
343344
let ident = &f.sig.ident;
344345

345346
quote!(
347+
#[doc(hidden)]
346348
#[export_name = #ident_s]
347349
pub unsafe extern "C" fn #tramp_ident() {
348350
extern crate core;
@@ -395,6 +397,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
395397
let ident = &f.sig.ident;
396398

397399
quote!(
400+
#[doc(hidden)]
398401
#[export_name = "HardFault"]
399402
#[link_section = ".HardFault.user"]
400403
pub unsafe extern "C" fn #tramp_ident(frame: &::cortex_m_rt::ExceptionFrame) {
@@ -481,6 +484,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream {
481484
.collect::<Vec<_>>();
482485

483486
quote!(
487+
#[doc(hidden)]
484488
#[export_name = #ident_s]
485489
pub unsafe extern "C" fn #tramp_ident() {
486490
#ident(
@@ -651,6 +655,7 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream {
651655
.collect::<Vec<_>>();
652656

653657
quote!(
658+
#[doc(hidden)]
654659
#[export_name = #ident_s]
655660
pub unsafe extern "C" fn #tramp_ident() {
656661
#ident(
@@ -730,6 +735,7 @@ pub fn pre_init(args: TokenStream, input: TokenStream) -> TokenStream {
730735

731736
quote!(
732737
#[export_name = "__pre_init"]
738+
#[allow(missing_docs)] // we make a private fn public, which can trigger this lint
733739
#(#attrs)*
734740
pub unsafe fn #ident() #block
735741
)

tests/compile-fail/exception-soundness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,5 @@ fn SysTick() {
2525
#[exception]
2626
fn SVCall() {
2727
// If this was allowed it would lead to a data race as `SVCall` could preempt `SysTick`
28-
SysTick(); //~ ERROR cannot find function `SysTick` in this scope
28+
SysTick(); //~ ERROR cannot find function, tuple struct or tuple variant `SysTick` in this scope [E0425]
2929
}

tests/compile-fail/interrupt-soundness.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,5 +30,5 @@ fn USART1() {
3030

3131
#[interrupt]
3232
fn USART2() {
33-
USART1(); //~ ERROR cannot find function `USART1` in this scope
33+
USART1(); //~ ERROR cannot find function, tuple struct or tuple variant `USART1` in this scope [E0425]
3434
}

0 commit comments

Comments
 (0)