Rules / TAU-C002

Async hazards

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

Why

Holding a lock across .await deadlocks, and dropping a future means the work never runs.

Fix

Release guards before awaiting; await or explicitly spawn-and-join futures.

What it checks

Lints: clippy::await_holding_lock, clippy::await_holding_refcell_ref, clippy::let_underscore_future, clippy::large_futures

Seen in fixtures

rej-await-lock/src/lib.rs edge

//! A lock guard held across an await point. use std::sync::Mutex; /// Bumps a counter around another future.pub async fn bump(counter: &Mutex<u8>, other: impl Future<Output = ()>) {    if let Ok(mut guard) = counter.lock() {        *guard = guard.saturating_add(1);        other.await;        drop(guard);    }}

$ cargo tauten check

error[TAU-C002]: this `MutexGuard` is held across an await point  --> rej-await-lock/src/lib.rs:7:15 (edge crate `rej-await-lock`)  = rule: Async hazards (decided by Clippy)  = fix: Release guards before awaiting; await or explicitly spawn-and-join futures.
Fixture rej-await-lock (edge) expects TAU-C002. Output captured at 0200db3.

In the terminal

cargo tauten explain TAU-C002

$ cargo tauten explain TAU-C002

TAU-C002: Async hazards Why: Holding a lock across `.await` deadlocks, and dropping a future means the work never runs. Fix: Release guards before awaiting; await or explicitly spawn-and-join futures. Decided by: ClippyDecides: No lock guard or `RefCell` borrow held across `.await`.Sees: resolved; complete: yesDoes not see: Code expanded from macros defined in other crates (clippy skips it); code disabled by `cfg`; build scripts.Applies to tests: yesExceptions allowed: with #[expect(.., reason)]  kernel deny  core deny  edge denyLints: clippy::await_holding_lock, clippy::await_holding_refcell_ref, clippy::let_underscore_future, clippy::large_futures