Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.concurrency

Prefer async mutex primitives in async functions

std::sync::Mutex in async code encourages blocking and await deadlocks.

#Metadata

Rule ID
rust.correctness.std-mutex-in-async-fn
Severity
medium
Confidence
0.85
Languages
rust
Presets
strict
Stability
stable
Applies to
block
Tags
concurrency, correctness, rules-catalog, rust

#Why it matters

`std::sync::Mutex` blocks the executor when contended. In `async fn`, prefer `tokio::sync::Mutex` or `async_lock` primitives that cooperate with the runtime.

#Remediation

Switch to `tokio::sync::Mutex` or keep blocking locks outside async contexts.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/rust/rust.correctness.std-mutex-in-async-fn.rule.yaml.