Skip to content

Enable the missing_inline_in_public_items clippy lint. #175

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/itm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use aligned::{Aligned, A4};
use crate::peripheral::itm::Stim;

// NOTE assumes that `bytes` is 32-bit aligned
#[allow(clippy::missing_inline_in_public_items)]
unsafe fn write_words(stim: &mut Stim, bytes: &[u32]) {
let mut p = bytes.as_ptr();
for _ in 0..bytes.len() {
Expand All @@ -30,6 +31,7 @@ impl<'p> fmt::Write for Port<'p> {

/// Writes a `buffer` to the ITM `port`
#[allow(clippy::cast_ptr_alignment)]
#[allow(clippy::missing_inline_in_public_items)]
#[allow(clippy::transmute_ptr_to_ptr)]
pub fn write_all(port: &mut Stim, buffer: &[u8]) {
unsafe {
Expand Down Expand Up @@ -90,6 +92,7 @@ pub fn write_all(port: &mut Stim, buffer: &[u8]) {
/// itm::write_aligned(&itm.stim[0], &Aligned(*b"Hello, world!\n"));
/// ```
#[allow(clippy::cast_ptr_alignment)]
#[allow(clippy::missing_inline_in_public_items)]
#[allow(clippy::transmute_ptr_to_ptr)]
pub fn write_aligned(port: &mut Stim, buffer: &Aligned<A4, [u8]>) {
unsafe {
Expand Down
15 changes: 15 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,21 @@
#![allow(clippy::identity_op)]
#![allow(clippy::missing_safety_doc)]

// This makes clippy warn about public functions which are not #[inline].
//
// Almost all functions in this crate result in trivial or even no assembly.
// These functions should be #[inline].
//
// If you do add a function that's not supposed to be #[inline], you can add
// #[allow(clippy::missing_inline_in_public_items)] in front of it to add an
// exception to clippy's rules.
//
// This should be done in case of:
// - A function containing non-trivial logic (such as itm::write_all); or
// - A generated #[derive(Debug)] function (in which case the attribute needs
// to be applied to the struct).
#![deny(clippy::missing_inline_in_public_items)]

extern crate aligned;
extern crate bare_metal;
extern crate volatile_register;
Expand Down
1 change: 1 addition & 0 deletions src/peripheral/cpuid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ pub struct RegisterBlock {

/// Type of cache to select on CSSELR writes.
#[cfg(not(armv6m))]
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum CsselrCacheType {
/// Select DCache or unified cache
Expand Down
4 changes: 4 additions & 0 deletions src/peripheral/scb.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ pub struct RegisterBlock {

/// FPU access mode
#[cfg(has_fpu)]
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum FpuAccessMode {
/// FPU is not accessible
Expand Down Expand Up @@ -193,6 +194,7 @@ impl SCB {
}

/// Processor core exceptions (internal interrupts)
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Exception {
/// Non maskable interrupt
Expand Down Expand Up @@ -258,6 +260,7 @@ impl Exception {
}

/// Active exception number
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum VectActive {
/// Thread mode
Expand Down Expand Up @@ -725,6 +728,7 @@ impl SCB {
}

/// System handlers, exceptions with configurable priority
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum SystemHandler {
// NonMaskableInt, // priority is fixed
Expand Down
1 change: 1 addition & 0 deletions src/peripheral/syst.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ pub struct RegisterBlock {
}

/// SysTick clock source
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SystClkSource {
/// Core-provided clock
Expand Down
1 change: 1 addition & 0 deletions src/register/apsr.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Application Program Status Register

/// Application Program Status Register
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug)]
pub struct Apsr {
bits: u32,
Expand Down
4 changes: 4 additions & 0 deletions src/register/control.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Control register

/// Control register
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug)]
pub struct Control {
bits: u32,
Expand Down Expand Up @@ -81,6 +82,7 @@ impl Control {
}

/// Thread mode privilege level
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Npriv {
/// Privileged
Expand All @@ -104,6 +106,7 @@ impl Npriv {
}

/// Currently active stack pointer
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Spsel {
/// MSP is the current stack pointer
Expand All @@ -127,6 +130,7 @@ impl Spsel {
}

/// Whether context floating-point is currently active
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Fpca {
/// Floating-point context active.
Expand Down
1 change: 1 addition & 0 deletions src/register/faultmask.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Fault Mask Register

/// All exceptions are ...
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Faultmask {
/// Active
Expand Down
1 change: 1 addition & 0 deletions src/register/primask.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
//! Priority mask register

/// All exceptions with configurable priority are ...
#[allow(clippy::missing_inline_in_public_items)]
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
pub enum Primask {
/// Active
Expand Down