Rules / TAU-C001

Structured concurrency only

decided by Clippy kernel deny core deny edge –
Applies to tests: no Exceptions: #[expect] + reason

Why

Detached threads and tasks can outlive their caller, leak errors and race with shutdown.

Fix

Use std::thread::scope, or tokio::task::JoinSet owned by the caller and awaited before returning.

What it checks

Banned in kernel, core (detached thread or task), 7 methods: std::thread::spawn, std::thread::Builder::spawn, tokio::spawn, tokio::task::spawn, tokio::task::spawn_blocking, tokio::task::spawn_local, async_std::task::spawn

Seen in fixtures

rej-detached-thread/src/lib.rs core

//! Detached thread. /// Fire and forget.pub fn background() {    drop(std::thread::spawn(|| {}));}

$ cargo tauten check

error[TAU-C001]: use of a disallowed method `std::thread::spawn`  --> rej-detached-thread/src/lib.rs:5:10 (core crate `rej-detached-thread`)  = rule: Structured concurrency only (decided by Clippy)  = fix: Use `std::thread::scope`, or `tokio::task::JoinSet` owned by the caller and awaited before returning.
Fixture rej-detached-thread (core) expects TAU-C001. Output captured at 0200db3.

In the terminal

cargo tauten explain TAU-C001

$ cargo tauten explain TAU-C001

TAU-C001: Structured concurrency only Why: Detached threads and tasks can outlive their caller, leak errors and race with shutdown. Fix: Use `std::thread::scope`, or `tokio::task::JoinSet` owned by the caller and awaited before returning. Decided by: ClippyDecides: No detached thread or task spawn outside the edge.Sees: resolved; complete: yesDoes not see: Code expanded from macros defined in other crates (clippy skips it); code disabled by `cfg`; build scripts. APIs not on the tier's ban list (clippy.toml), including dependency functions that wrap a banned one; foreign code.Applies to tests: noExceptions allowed: with #[expect(.., reason)]  kernel deny  core deny  edge -Banned (detached thread or task): std::thread::spawn, std::thread::Builder::spawn, tokio::spawn, tokio::task::spawn, tokio::task::spawn_blocking, tokio::task::spawn_local, async_std::task::spawn