← Rule catalog

Source kernel · Reliability

Blocking call made directly inside async code

rust_doctor::source::blocking_call_in_async

Use the async equivalent (tokio::fs, tokio::time::sleep, tokio::process, reqwest's async client) or move the call into tokio::task::spawn_blocking; the rule also follows a call into a synchronous helper of the same file, four helpers deep, and reports it at the call made from async code.

Category
Reliability
Default level
warn
Tier
P2
Producer
Source kernel
Diff scope
item

Not a defect when

The call runs once at startup before the runtime serves concurrent tasks, such as reading a config file at the top of an async main, or the future is driven by block_on on a dedicated thread.

What it reads

Source text, without resolving types or expanding macros.

Tier

Ordinary defect.

The tier bounds how severe a rule may be; its category bounds the tier.

Diff scope

The function or item around the changed line.

What --scope contextual looks at to decide whether a change caused the finding.

Change it

Turn it off, or make it blocking, without touching the code it flags:

rust-doctor --rule rust_doctor::source::blocking_call_in_async=off .
rust-doctor --rule rust_doctor::source::blocking_call_in_async=error .

Set it once in rust-doctor.toml

Other Reliability rules