Rules / TAU-K003

Kernel crate attributes

decided by Tauten kernel deny core – edge –
Applies to tests: yes Exceptions: never

Why

A kernel crate root must declare #![no_std] so the compiler enforces the absence of IO.

Fix

Add #![no_std] (or #![cfg_attr(not(test), no_std)]) at the top of the kernel crate's lib.rs, with no other condition.

Seen in fixtures

rej-conditional-no-std/src/lib.rs kernel

#![cfg_attr(not(feature = "std"), no_std)]//! A kernel that is `no_std` only while the `std` feature is off. /// The larger of two values.#[must_use]pub const fn larger(a: u32, b: u32) -> u32 {    if a > b { a } else { b }}

$ cargo tauten check

error[TAU-K003]: kernel crate `rej-conditional-no-std` declares `no_std` only under a condition other than `not(test)`  --> rej-conditional-no-std/src/lib.rs:1:1 (kernel crate `rej-conditional-no-std`)  = rule: Kernel crate attributes (decided by Tauten)  = fix: Add `#![no_std]` (or `#![cfg_attr(not(test), no_std)]`) at the top of the kernel crate's `lib.rs`, with no other condition.
Fixture rej-conditional-no-std (kernel) expects TAU-K003. Output captured at 0200db3.

rej-kernel-impure/src/lib.rs kernel

//! Kernel without no_std, using HashMap and floats. use std::collections::HashMap; /// Count keys.#[must_use]pub fn count(map: &HashMap<u8, u8>) -> usize {    map.len()} /// Average.#[must_use]pub fn half(x: f64) -> f64 {    x / 2.0}

$ cargo tauten check

error[TAU-K003]: kernel crate `rej-kernel-impure` is missing `#![no_std]`  --> rej-kernel-impure/src/lib.rs:1:1 (kernel crate `rej-kernel-impure`)  = rule: Kernel crate attributes (decided by Tauten)  = fix: Add `#![no_std]` (or `#![cfg_attr(not(test), no_std)]`) at the top of the kernel crate's `lib.rs`, with no other condition.
Fixture rej-kernel-impure (kernel) expects TAU-K003, TAU-K001, TAU-N003. Output captured at 0200db3.

In the terminal

cargo tauten explain TAU-K003

$ cargo tauten explain TAU-K003

TAU-K003: Kernel crate attributes Why: A kernel crate root must declare `#![no_std]` so the compiler enforces the absence of IO. Fix: Add `#![no_std]` (or `#![cfg_attr(not(test), no_std)]`) at the top of the kernel crate's `lib.rs`, with no other condition. Decided by: TautenDecides: A kernel library root declares `#![no_std]` unconditionally or as `#![cfg_attr(not(test), no_std)]`; any other condition, and a root that does not parse, is a finding.Sees: source; complete: yesDoes not see: Nothing: the crate root is read in full.Applies to tests: yesExceptions allowed: with #[expect(.., reason)]  kernel deny  core -  edge -