From 72f0cc505addf00d493b764418e4207f53434152 Mon Sep 17 00:00:00 2001 From: Jorge Aparicio Date: Sat, 23 Feb 2019 21:54:56 +0100 Subject: [PATCH] make cfail test actually fail --- macros/src/check.rs | 12 +++++++++--- tests/cfail/used-free-interrupt-2.rs | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/macros/src/check.rs b/macros/src/check.rs index 464e280ac1..ab86461612 100644 --- a/macros/src/check.rs +++ b/macros/src/check.rs @@ -106,10 +106,16 @@ pub fn app(app: &App) -> parse::Result<()> { } // Check that free interrupts are not being used - for int in app.interrupts.keys() { - if app.free_interrupts.contains_key(int) { + for (name, interrupt) in &app.interrupts { + let name = if let Some(ref binds) = interrupt.args.binds { + binds + } else { + name + }; + + if app.free_interrupts.contains_key(name) { return Err(parse::Error::new( - int.span(), + name.span(), "free interrupts (`extern { .. }`) can't be used as interrupt handlers", )); } diff --git a/tests/cfail/used-free-interrupt-2.rs b/tests/cfail/used-free-interrupt-2.rs index f9aab78efd..616d308d0d 100644 --- a/tests/cfail/used-free-interrupt-2.rs +++ b/tests/cfail/used-free-interrupt-2.rs @@ -12,8 +12,8 @@ const APP: () = { #[init] fn init() {} - #[interrupt(binds = UART0)] - fn foo() {} //~ ERROR free interrupts (`extern { .. }`) can't be used as interrupt handlers + #[interrupt(binds = UART0)] //~ ERROR free interrupts (`extern { .. }`) can't be used as interrupt handlers + fn foo() {} extern "C" { fn UART0();