From 4741844640b5bc3cbb756274817d45a2b449e090 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Sat, 28 Dec 2019 14:52:17 +0100 Subject: [PATCH 1/7] Hide trampolines from docs --- macros/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 543130c9..b46721a5 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -151,6 +151,7 @@ pub fn entry(args: TokenStream, input: TokenStream) -> TokenStream { .collect::>(); quote!( + #[doc(hidden)] #[export_name = "main"] pub unsafe extern "C" fn #tramp_ident() { #ident( From 431f6d85bff04a32aed30a4f9a832b1754efc35d Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Sat, 28 Dec 2019 15:19:21 +0100 Subject: [PATCH 2/7] Added missing hidden doc --- macros/src/lib.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index b46721a5..5457f596 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -344,6 +344,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { let ident = &f.sig.ident; quote!( + #[doc(hidden)] #[export_name = #ident_s] pub unsafe extern "C" fn #tramp_ident() { extern crate core; @@ -396,6 +397,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { let ident = &f.sig.ident; quote!( + #[doc(hidden)] #[export_name = "HardFault"] #[link_section = ".HardFault.user"] pub unsafe extern "C" fn #tramp_ident(frame: &::cortex_m_rt::ExceptionFrame) { @@ -482,6 +484,7 @@ pub fn exception(args: TokenStream, input: TokenStream) -> TokenStream { .collect::>(); quote!( + #[doc(hidden)] #[export_name = #ident_s] pub unsafe extern "C" fn #tramp_ident() { #ident( @@ -652,6 +655,7 @@ pub fn interrupt(args: TokenStream, input: TokenStream) -> TokenStream { .collect::>(); quote!( + #[doc(hidden)] #[export_name = #ident_s] pub unsafe extern "C" fn #tramp_ident() { #ident( From 0b2704b070d417bad49ea86c064cf66f3bb48e52 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 26 Jan 2020 18:26:13 +0100 Subject: [PATCH 3/7] `#[allow(missing_docs)]` on `#[pre_init]` hooks --- macros/src/lib.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/macros/src/lib.rs b/macros/src/lib.rs index 5457f596..8ffb0064 100644 --- a/macros/src/lib.rs +++ b/macros/src/lib.rs @@ -735,6 +735,7 @@ pub fn pre_init(args: TokenStream, input: TokenStream) -> TokenStream { quote!( #[export_name = "__pre_init"] + #[allow(missing_docs)] // we make a private fn public, which can trigger this lint #(#attrs)* pub unsafe fn #ident() #block ) From b25b619abebdf1fbd1313321e38483fe0698cd83 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 26 Jan 2020 18:26:28 +0100 Subject: [PATCH 4/7] Add a test that enables ALL the warnings --- Cargo.toml | 4 ++++ examples/warnings.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 examples/warnings.rs diff --git a/Cargo.toml b/Cargo.toml index e4c3b6a2..bcbd6007 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -31,6 +31,10 @@ compiletest_rs = "0.4.0" name = "device" required-features = ["device"] +[[example]] +name = "warnings" +required-features = ["device"] + [[test]] name = "compiletest" required-features = ["device"] diff --git a/examples/warnings.rs b/examples/warnings.rs new file mode 100644 index 00000000..33720031 --- /dev/null +++ b/examples/warnings.rs @@ -0,0 +1,50 @@ +//! Tests that a crate can still build with all warnings enabled. +//! +//! The code generated by the `cortex-m-rt` macros might need to manually +//! `#[allow]` some of them (even though Rust does that by default for a few +//! warnings too). + +#![no_std] +#![no_main] +#![deny(warnings, missing_docs, rust_2018_idioms)] + +extern crate cortex_m_rt; +extern crate panic_halt; + +use cortex_m_rt::{entry, exception, interrupt, pre_init, ExceptionFrame}; + +#[allow(non_camel_case_types)] +enum interrupt { + INT, +} + +extern "C" { + fn INT(); +} + +union Vector { + #[allow(dead_code)] + handler: unsafe extern "C" fn(), +} + +#[link_section = ".vector_table.interrupts"] +#[no_mangle] +#[used] +static __INTERRUPTS: [Vector; 1] = [Vector { handler: INT }]; + +/// Dummy interrupt. +#[interrupt] +fn INT() {} + +#[exception] +fn HardFault(_eh: &ExceptionFrame) -> ! { + loop {} +} + +#[entry] +fn main() -> ! { + loop {} +} + +#[pre_init] +unsafe fn pre_init() {} From f31ec875453753158352fa033bc65e69e24a2e43 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 26 Jan 2020 19:24:52 +0100 Subject: [PATCH 5/7] Update error message to pass compile-fail tests --- tests/compile-fail/exception-soundness.rs | 2 +- tests/compile-fail/interrupt-soundness.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/compile-fail/exception-soundness.rs b/tests/compile-fail/exception-soundness.rs index aae24769..9a1e10b0 100644 --- a/tests/compile-fail/exception-soundness.rs +++ b/tests/compile-fail/exception-soundness.rs @@ -25,5 +25,5 @@ fn SysTick() { #[exception] fn SVCall() { // If this was allowed it would lead to a data race as `SVCall` could preempt `SysTick` - SysTick(); //~ ERROR cannot find function `SysTick` in this scope + SysTick(); //~ ERROR cannot find function, tuple struct or tuple variant `SysTick` in this scope [E0425] } diff --git a/tests/compile-fail/interrupt-soundness.rs b/tests/compile-fail/interrupt-soundness.rs index 74e5e79e..faf737dc 100644 --- a/tests/compile-fail/interrupt-soundness.rs +++ b/tests/compile-fail/interrupt-soundness.rs @@ -30,5 +30,5 @@ fn USART1() { #[interrupt] fn USART2() { - USART1(); //~ ERROR cannot find function `USART1` in this scope + USART1(); //~ ERROR cannot find function, tuple struct or tuple variant `USART1` in this scope [E0425] } From 24afb1d0ce643f701383866d362cf7e5cbdf1c52 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 26 Jan 2020 20:24:40 +0100 Subject: [PATCH 6/7] Bump crate versions --- Cargo.toml | 4 ++-- macros/Cargo.toml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index bcbd6007..8c914ab1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,12 +12,12 @@ license = "MIT OR Apache-2.0" name = "cortex-m-rt" readme = "README.md" repository = "https://github.com/rust-embedded/cortex-m-rt" -version = "0.6.11" +version = "0.6.12" autoexamples = true [dependencies] r0 = "0.2.2" -cortex-m-rt-macros = { path = "macros", version = "0.1" } +cortex-m-rt-macros = { path = "macros", version = "=0.1.8" } [dev-dependencies] cortex-m = "0.6" diff --git a/macros/Cargo.toml b/macros/Cargo.toml index 9beb8f97..34425b2b 100644 --- a/macros/Cargo.toml +++ b/macros/Cargo.toml @@ -7,7 +7,7 @@ keywords = ["arm", "cortex-m", "runtime", "startup"] license = "MIT OR Apache-2.0" name = "cortex-m-rt-macros" repository = "https://github.com/japaric/cortex-m-rt" -version = "0.1.7" +version = "0.1.8" edition = "2018" [lib] From 00d300b2e995304ff0056c3558382c4dd205c873 Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sun, 26 Jan 2020 20:31:38 +0100 Subject: [PATCH 7/7] Update changelog for 0.6.12 --- CHANGELOG.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9325bc9b..00816629 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## [Unreleased] +## [v0.6.12] - 2020-01-26 + +### Fixed + +- Fixed lint warnings getting emitted on macro-generated code. + +## [v0.6.11] - 2019-12-04 + ### Changed - Macros now generate a second trampoline function instead of randomizing the @@ -466,7 +474,9 @@ section size addr Initial release -[Unreleased]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.10...HEAD +[Unreleased]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.12...HEAD +[v0.6.12]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.11...v0.6.12 +[v0.6.11]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.10...v0.6.11 [v0.6.10]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.9...v0.6.10 [v0.6.9]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.8...v0.6.9 [v0.6.8]: https://github.com/rust-embedded/cortex-m-rt/compare/v0.6.7...v0.6.8