From cd445165c50a46042e0cf17eb0081879f9cf4d52 Mon Sep 17 00:00:00 2001 From: Emil Fresk Date: Tue, 17 May 2022 20:12:36 +0200 Subject: [PATCH] More ergonomic error from static asserts messages --- macros/src/codegen/pre_init.rs | 25 ++++++++++++++++++++++--- ui/task-priority-too-high.stderr | 14 +++++++++++--- 2 files changed, 33 insertions(+), 6 deletions(-) diff --git a/macros/src/codegen/pre_init.rs b/macros/src/codegen/pre_init.rs index 91c9991274b4..ae2fd0503fae 100644 --- a/macros/src/codegen/pre_init.rs +++ b/macros/src/codegen/pre_init.rs @@ -49,8 +49,14 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec= #priority as usize, #es); + )); stmts.push(quote!( core.NVIC.set_priority( @@ -72,8 +78,14 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec= #priority as usize, #es); + )); stmts.push(quote!(core.SCB.set_priority( rtic::export::SystemHandler::#name, @@ -90,8 +102,15 @@ pub fn codegen(app: &App, analysis: &Analysis, extra: &Extra) -> Vec= #priority as usize, #es); + )); let mono_type = &monotonic.ty; diff --git a/ui/task-priority-too-high.stderr b/ui/task-priority-too-high.stderr index e0978f718860..a5ce918a4c92 100644 --- a/ui/task-priority-too-high.stderr +++ b/ui/task-priority-too-high.stderr @@ -1,7 +1,15 @@ +warning: unused variable: `cx` + --> ui/task-priority-too-high.rs:12:13 + | +12 | fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) { + | ^^ help: if this is intentional, prefix it with an underscore: `_cx` + | + = note: `#[warn(unused_variables)]` on by default + error[E0080]: evaluation of constant value failed - --> $DIR/task-priority-too-high.rs:3:1 + --> ui/task-priority-too-high.rs:3:1 | 3 | #[rtic::app(device = lm3s6965)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attempt to compute `8_usize - 9_usize`, which would overflow + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the evaluated program panicked at 'Maximum priority used by interrupt vector 'I2C0' is more than supported by hardware', $DIR/ui/task-priority-too-high.rs:3:1 | - = note: this error originates in the attribute macro `rtic::app` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)