From 26ee7b26c3d619a34b659e96fb7e2fcd22f02bb4 Mon Sep 17 00:00:00 2001 From: ROMemories <152802150+ROMemories@users.noreply.github.com> Date: Wed, 18 Sep 2024 14:05:15 +0200 Subject: [PATCH] chore: make clippy happy Some of these come from new lints brought by updating the toolchain, others are lingering warning fixes. --- src/riot-rs-embassy-common/src/gpio.rs | 7 ++++--- src/riot-rs-embassy-common/src/lib.rs | 1 + src/riot-rs-embassy/src/arch/gpio.rs | 10 ++++++++-- src/riot-rs-embassy/src/delegate.rs | 2 +- src/riot-rs-embassy/src/gpio.rs | 4 ++++ src/riot-rs-macros/src/task.rs | 4 ++-- src/riot-rs-macros/src/utils.rs | 2 +- src/riot-rs-runqueue/src/runqueue.rs | 1 + 8 files changed, 22 insertions(+), 9 deletions(-) diff --git a/src/riot-rs-embassy-common/src/gpio.rs b/src/riot-rs-embassy-common/src/gpio.rs index 8b068cf13..06c436e83 100644 --- a/src/riot-rs-embassy-common/src/gpio.rs +++ b/src/riot-rs-embassy-common/src/gpio.rs @@ -20,9 +20,10 @@ impl From for bool { impl From for Level { fn from(boolean: bool) -> Self { - match boolean { - false => Level::Low, - true => Level::High, + if boolean { + Level::High + } else { + Level::Low } } } diff --git a/src/riot-rs-embassy-common/src/lib.rs b/src/riot-rs-embassy-common/src/lib.rs index 05c30d6f2..88f370951 100644 --- a/src/riot-rs-embassy-common/src/lib.rs +++ b/src/riot-rs-embassy-common/src/lib.rs @@ -2,6 +2,7 @@ #![no_std] #![feature(doc_auto_cfg)] +#![deny(clippy::pedantic)] #![deny(missing_docs)] pub mod gpio; diff --git a/src/riot-rs-embassy/src/arch/gpio.rs b/src/riot-rs-embassy/src/arch/gpio.rs index feec10f20..d02cd72eb 100644 --- a/src/riot-rs-embassy/src/arch/gpio.rs +++ b/src/riot-rs-embassy/src/arch/gpio.rs @@ -134,7 +134,10 @@ pub mod output { /// Actual type is architecture-specific. #[derive(Copy, Clone, PartialEq, Eq)] - pub enum DriveStrength {} + pub enum DriveStrength { + #[doc(hidden)] + Hidden, + } impl FromDriveStrength for DriveStrength { fn from(_drive_strength: crate::gpio::DriveStrength) -> Self { @@ -144,7 +147,10 @@ pub mod output { /// Actual type is architecture-specific. #[derive(Copy, Clone, PartialEq, Eq)] - pub enum Speed {} + pub enum Speed { + #[doc(hidden)] + Hidden, + } impl FromSpeed for Speed { fn from(_speed: crate::gpio::Speed) -> Self { diff --git a/src/riot-rs-embassy/src/delegate.rs b/src/riot-rs-embassy/src/delegate.rs index acacd4ff7..626bc955e 100644 --- a/src/riot-rs-embassy/src/delegate.rs +++ b/src/riot-rs-embassy/src/delegate.rs @@ -34,7 +34,7 @@ use crate::sendcell::SendCell; /// TODO: this is a PoC implementation. /// - takes 24b for each delegate (on arm), which seems too much. /// - doesn't protect at all against calling [`lend()`](Delegate::lend) or -/// [`with()`](Delegate::with) multiple times +/// [`with()`](Delegate::with) multiple times /// each, breaking safety assumptions. So while the API seems OK, the implementation /// needs work. #[derive(Default)] diff --git a/src/riot-rs-embassy/src/gpio.rs b/src/riot-rs-embassy/src/gpio.rs index 95263fee2..7c3772377 100644 --- a/src/riot-rs-embassy/src/gpio.rs +++ b/src/riot-rs-embassy/src/gpio.rs @@ -210,6 +210,10 @@ pub mod input { /// Fails to compile if the architecture does not support configuring Schmitt trigger on /// inputs. pub fn schmitt_trigger(self, enable: bool) -> Self { + #[expect( + clippy::assertions_on_constants, + reason = "the constant depends on the architecture" + )] const { assert!( arch::gpio::input::SCHMITT_TRIGGER_CONFIGURABLE, diff --git a/src/riot-rs-macros/src/task.rs b/src/riot-rs-macros/src/task.rs index 34e08e6a0..085eab971 100644 --- a/src/riot-rs-macros/src/task.rs +++ b/src/riot-rs-macros/src/task.rs @@ -17,8 +17,8 @@ /// The peripheral struct must be defined with the `riot_rs::define_peripherals!` macro. /// - hooks: (*optional*) available hooks are: /// - `usb_builder_hook`: when present, the macro will define a static `USB_BUILDER_HOOK` -/// of type `UsbBuilderHook`, allowing to access and modify the system-provided -/// `embassy_usb::Builder` through `Delegate::with()`, *before* it is built by the system. +/// of type `UsbBuilderHook`, allowing to access and modify the system-provided +/// `embassy_usb::Builder` through `Delegate::with()`, *before* it is built by the system. /// - `pool_size`: (*optional*) set the maximum number of concurrent tasks that can be spawned for /// the function (defaults to `1`). /// Cannot be used on `autostart` tasks. diff --git a/src/riot-rs-macros/src/utils.rs b/src/riot-rs-macros/src/utils.rs index ef361885a..14b334675 100644 --- a/src/riot-rs-macros/src/utils.rs +++ b/src/riot-rs-macros/src/utils.rs @@ -7,7 +7,7 @@ const RIOT_RS_CRATE_NAME: &str = "riot-rs"; /// # Panics /// /// - Panics when the `riot-rs` crate cannot be found as a dependency of the crate in which -/// this function is called. +/// this function is called. /// - Panics if `riot-rs` is used as a dependency of itself. pub fn riot_rs_crate() -> syn::Ident { find_crate(RIOT_RS_CRATE_NAME) diff --git a/src/riot-rs-runqueue/src/runqueue.rs b/src/riot-rs-runqueue/src/runqueue.rs index ede55bcaa..3c67efb6b 100644 --- a/src/riot-rs-runqueue/src/runqueue.rs +++ b/src/riot-rs-runqueue/src/runqueue.rs @@ -125,6 +125,7 @@ impl RunQueue<{ N_QUEUES }, { N_T mod clist { //! This module implements an array of `N_QUEUES` circular linked lists over an //! array of size `N_THREADS`. + //! //! The array is used for "next" pointers, so each integer value in the array //! corresponds to one element, which can only be in one of the lists. #[derive(Debug, Copy, Clone)]