Skip to content

Commit

Permalink
refactor(kernel): address clippy lints
Browse files Browse the repository at this point in the history
- `len_without_is_empty`
- `declare_interior_mutable_const` (ignored)
- `missing_safety_doc` (ignored)

Unaddressed:
- `redundant_pattern_matching` - This is a bug in clippy:
  <rust-lang/rust-clippy#5697>
  • Loading branch information
yvt committed Jun 9, 2020
1 parent 7cec0ef commit a85847a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/constance/src/kernel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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.
///
Expand Down
4 changes: 4 additions & 0 deletions src/constance/src/kernel/cfg/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@ impl<T: Copy> ComptimeVec<T> {
self.len
}

pub const fn is_empty(&self) -> bool {
self.len == 0
}

// FIXME: Waiting for <https://github.com/rust-lang/rust/issues/67792>
pub const fn get(&self, i: usize) -> T {
if i >= self.len() {
Expand Down

0 comments on commit a85847a

Please sign in to comment.