Skip to content

F0107 cls-2

Rule: A service module denies the Clippy lints that find panics at its top.

Code F0107 (stable, never reused)
Id cls-2
Category cls
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded deny a service module never reaches the panic handler in release; Clippy finds its panics at build time. Fires only where classes are declared
ui off
egui off
units-strict off
units-paranoid off

Parameters

Name Type Default Meaning
lints list of strings ["clippy::unwrap_used", "clippy::expect_used", "clippy::panic", "clippy::unreachable", "clippy::indexing_slicing", "clippy::arithmetic_side_effects"] the lints a service module denies or forbids in an inner attribute

Why

A service module (LED, logging, telemetry) must never reach the panic handler in a release build: the system does not reset for a LED. Clippy finds the panicking constructs at build time when the module denies them:

#![deny(
    clippy::unwrap_used,
    clippy::expect_used,
    clippy::panic,
    clippy::unreachable,
    clippy::indexing_slicing,
    clippy::arithmetic_side_effects
)]

Clippy has no lint for assert!; the embedded tier's panic-in-library checks the macros in service modules.

Example

A LED task finds a period of zero. It has debug_assert!(period_ms > 0, "LED period"), then let period = period_ms.max(1) and cnt!(led_bad_period: u32, warn): a development build stops at the assertion, a release build counts and keeps blinking.

How to fix

Put the attribute at the top of the file (the parameter lints lists what it must deny). Handle each case it then reports with a Result, .get(i), checked_*, a debug_assert!, a counter and a fallback.

How it is checked

src: the inner deny and forbid attributes of each file [embedded.classes] puts in service.

Configure

[lints.cls-2]
level = "deny"
lints = ["clippy::unwrap_used", "clippy::expect_used", "clippy::panic", "clippy::unreachable", "clippy::indexing_slicing", "clippy::arithmetic_side_effects"]
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(cls-2) <reason> (waivers); the code works there too, as in [lints.F0107].