From a85847ad795a1a2fbdf5092c990df8f6b2a8d541 Mon Sep 17 00:00:00 2001 From: yvt Date: Tue, 9 Jun 2020 11:56:17 +0900 Subject: [PATCH] refactor(kernel): address clippy lints - `len_without_is_empty` - `declare_interior_mutable_const` (ignored) - `missing_safety_doc` (ignored) Unaddressed: - `redundant_pattern_matching` - This is a bug in clippy: --- src/constance/src/kernel.rs | 3 +++ src/constance/src/kernel/cfg/vec.rs | 4 ++++ 2 files changed, 7 insertions(+) diff --git a/src/constance/src/kernel.rs b/src/constance/src/kernel.rs index 79a3f19352..4f54121aa2 100644 --- a/src/constance/src/kernel.rs +++ b/src/constance/src/kernel.rs @@ -81,10 +81,12 @@ pub unsafe trait KernelCfg1: Sized + 'static { /// implementation. /// /// These methods are only meant to be called by the kernel. +#[allow(clippy::missing_safety_doc)] pub unsafe trait Port: KernelCfg1 { type PortTaskState: Send + Sync + Init + 'static; /// The initial value of [`TaskCb::port_task_state`] for all tasks. + #[allow(clippy::declare_interior_mutable_const)] // it's intentional const PORT_TASK_STATE_INIT: Self::PortTaskState; /// The default stack size for tasks. @@ -148,6 +150,7 @@ pub unsafe trait Port: KernelCfg1 { /// # Safety /// /// These are only meant to be called by the port. +#[allow(clippy::missing_safety_doc)] pub trait PortToKernel { /// Initialize runtime structures. /// diff --git a/src/constance/src/kernel/cfg/vec.rs b/src/constance/src/kernel/cfg/vec.rs index 8d3748ab93..8eb59753a0 100644 --- a/src/constance/src/kernel/cfg/vec.rs +++ b/src/constance/src/kernel/cfg/vec.rs @@ -28,6 +28,10 @@ impl ComptimeVec { self.len } + pub const fn is_empty(&self) -> bool { + self.len == 0 + } + // FIXME: Waiting for pub const fn get(&self, i: usize) -> T { if i >= self.len() {