Static rustc_lint::builtin::MUST_NOT_SUSPEND

source ·
pub static MUST_NOT_SUSPEND: &'static Lint
Expand description

The must_not_suspend lint guards against values that shouldn’t be held across suspend points (.await)



struct SyncThing {}

async fn yield_now() {}

pub async fn uhoh() {
    let guard = SyncThing {};
    let _guard = guard;



The must_not_suspend lint detects values that are marked with the #[must_not_suspend] attribute being held across suspend points. A “suspend” point is usually a .await in an async function.

This attribute can be used to mark values that are semantically incorrect across suspends (like certain types of timers), values that have async alternatives, and values that regularly cause problems with the Send-ness of async fn’s returned futures (like MutexGuard’s)