From db8bea29e61d4659942539f8da7fe4f39c02729f Mon Sep 17 00:00:00 2001 From: Adam Greig Date: Thu, 24 Feb 2022 17:31:00 +0000 Subject: [PATCH] Add a free() method for non-cortex-m build targets that panics, to allow checking code that uses it on native platform. --- src/interrupt.rs | 12 ++++++++++++ src/peripheral/tpiu.rs | 1 - 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/interrupt.rs b/src/interrupt.rs index 06b91f17..72450c4b 100644 --- a/src/interrupt.rs +++ b/src/interrupt.rs @@ -77,3 +77,15 @@ where r } + +// Make a `free()` function available to allow checking dependencies without specifying a target, +// but that will panic at runtime if executed. +#[doc(hidden)] +#[cfg(not(cortex_m))] +#[inline] +pub fn free(_: F) -> R +where + F: FnOnce(&CriticalSection) -> R, +{ + panic!("cortex_m::interrupt::free() is only functional on cortex-m platforms"); +} diff --git a/src/peripheral/tpiu.rs b/src/peripheral/tpiu.rs index 07624951..14dd35ca 100644 --- a/src/peripheral/tpiu.rs +++ b/src/peripheral/tpiu.rs @@ -118,7 +118,6 @@ impl TPIU { /// [`trace_output_protocol`](Self::set_trace_output_protocol). #[inline] pub fn trace_output_protocol(&self) -> Option { - use core::convert::TryInto; self.sppr.read().txmode().try_into().ok() }