Clippy with pedantic suggestions

This commit is contained in:
Henrik Tjäder 2022-02-18 19:38:48 +01:00
parent 57da1e0403
commit 5ed93bd1bf
17 changed files with 84 additions and 84 deletions

View file

@ -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<T, R>(
}
/// 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<T, R>(
}
#[inline]
#[must_use]
pub fn logical2hw(logical: u8, nvic_prio_bits: u8) -> u8 {
((1 << nvic_prio_bits) - logical) << (8 - nvic_prio_bits)
}

View file

@ -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<I>(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<T>
/// Implementation uses the underlying ``UnsafeCell<T>``
/// 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<T>
/// Implementation uses the underlying ``UnsafeCell<T>``
/// self.0.get() -> *mut T, demoted to *const T
///
///
#[repr(transparent)]
pub struct RacyCell<T>(UnsafeCell<T>);
impl<T> RacyCell<T> {
/// Create a RacyCell
/// Create a ``RacyCell``
#[inline(always)]
pub const fn new(value: T) -> Self {
RacyCell(UnsafeCell::new(value))

View file

@ -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<F>(&mut self, disable_interrupt: F, mono: &mut Mono) -> Option<(Task, u8)>
where
F: FnOnce(),