From 5ed93bd1bf056f1d2b8632502300d7488df4e9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Henrik=20Tj=C3=A4der?= Date: Fri, 18 Feb 2022 19:38:48 +0100 Subject: Clippy with pedantic suggestions --- src/export.rs | 8 +++++--- src/lib.rs | 13 +++++++------ src/tq.rs | 11 ++++------- 3 files changed, 16 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/export.rs b/src/export.rs index a124c78..838ae84 100644 --- a/src/export.rs +++ b/src/export.rs @@ -1,3 +1,4 @@ +#![allow(clippy::inline_always)] use core::{ cell::Cell, sync::atomic::{AtomicBool, Ordering}, @@ -61,7 +62,7 @@ impl Barrier { } pub fn release(&self) { - self.inner.store(true, Ordering::Release) + self.inner.store(true, Ordering::Release); } pub fn wait(&self) { @@ -91,7 +92,7 @@ impl Priority { // These two methods are used by `lock` (see below) but can't be used from the RTIC application #[inline(always)] fn set(&self, value: u8) { - self.inner.set(value) + self.inner.set(value); } /// Get the current priority @@ -160,7 +161,7 @@ pub unsafe fn lock( } /// Lock the resource proxy by setting the PRIMASK -/// and running the closure with interrupt::free +/// and running the closure with ``interrupt::free`` /// /// # Safety /// @@ -188,6 +189,7 @@ pub unsafe fn lock( } #[inline] +#[must_use] pub fn logical2hw(logical: u8, nvic_prio_bits: u8) -> u8 { ((1 << nvic_prio_bits) - logical) << (8 - nvic_prio_bits) } diff --git a/src/lib.rs b/src/lib.rs index 871141f..0c0d0cc 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,6 +36,7 @@ html_favicon_url = "https://raw.githubusercontent.com/rtic-rs/cortex-m-rtic/master/book/en/src/RTIC.svg" )] //deny_warnings_placeholder_for_ci +#![allow(clippy::inline_always)] use cortex_m::{interrupt::InterruptNumber, peripheral::NVIC}; pub use cortex_m_rtic_macros::app; @@ -61,7 +62,7 @@ pub fn pend(interrupt: I) where I: InterruptNumber, { - NVIC::pend(interrupt) + NVIC::pend(interrupt); } use core::cell::UnsafeCell; @@ -72,12 +73,12 @@ use core::cell::UnsafeCell; /// /// Soundness: /// 1) Unsafe API for internal use only -/// 2) get_mut(&self) -> *mut T +/// 2) ``get_mut(&self) -> *mut T`` /// returns a raw mutable pointer to the inner T /// casting to &mut T is under control of RTIC /// RTIC ensures &mut T to be unique under Rust aliasing rules. /// -/// Implementation uses the underlying UnsafeCell +/// Implementation uses the underlying ``UnsafeCell`` /// self.0.get() -> *mut T /// /// 3) get(&self) -> *const T @@ -85,14 +86,14 @@ use core::cell::UnsafeCell; /// casting to &T is under control of RTIC /// RTIC ensures &T to be shared under Rust aliasing rules. /// -/// Implementation uses the underlying UnsafeCell +/// Implementation uses the underlying ``UnsafeCell`` /// self.0.get() -> *mut T, demoted to *const T -/// +/// #[repr(transparent)] pub struct RacyCell(UnsafeCell); impl RacyCell { - /// Create a RacyCell + /// Create a ``RacyCell`` #[inline(always)] pub const fn new(value: T) -> Self { RacyCell(UnsafeCell::new(value)) diff --git a/src/tq.rs b/src/tq.rs index 9033022..0f585ba 100644 --- a/src/tq.rs +++ b/src/tq.rs @@ -17,7 +17,7 @@ where /// # Safety /// /// Writing to memory with a transmute in order to enable - /// interrupts of the SysTick timer + /// interrupts of the ``SysTick`` timer /// /// Enqueue a task without checking if it is full #[inline] @@ -33,11 +33,8 @@ where { // Check if the top contains a non-empty element and if that element is // greater than nr - let if_heap_max_greater_than_nr = self - .0 - .peek() - .map(|head| nr.instant < head.instant) - .unwrap_or(true); + let if_heap_max_greater_than_nr = + self.0.peek().map_or(true, |head| nr.instant < head.instant); if if_heap_max_greater_than_nr { if Mono::DISABLE_INTERRUPT_ON_EMPTY_QUEUE && self.0.is_empty() { @@ -92,7 +89,7 @@ where } } - /// Dequeue a task from the TimerQueue + /// Dequeue a task from the ``TimerQueue`` pub fn dequeue(&mut self, disable_interrupt: F, mono: &mut Mono) -> Option<(Task, u8)> where F: FnOnce(), -- cgit v1.2.3