You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Checks for functions that are declared async but have no .awaits inside of them.
Categories (optional)
Kind: pedantic
Reduces code smell and overhead by encouraging async functions to be refactored to synchronous functions.
Drawbacks
There are valid cases where a programmer may want to wrap synchronous code in an asynchronous future: for example, spawning a synchronous task on an asynchronous scheduler, or implementing an async function for a trait where the implementation is synchronous. These cases are the reason this lint is pedantic. However, there are a few additional steps I want to take with this lint to avoid causing hassle or confusion for programmers:
This lint should avoid trait functions, as there are valid reasons why an async trait function might have a non-async implementation.
This lint should recommend to the programmer the proper way to make an synchronous task into a future: using the async {} block.
Example
asyncfnget_random_number() -> i64{4// Chosen by fair dice roll. Guaranteed to be random.}
Could be written as:
fnget_random_number() -> i64{4// Chosen by fair dice roll. Guaranteed to be random.}
Something like this, however, should not be caught by clippy:
What it does
Checks for functions that are declared
async
but have no.await
s inside of them.Categories (optional)
Reduces code smell and overhead by encouraging async functions to be refactored to synchronous functions.
Drawbacks
There are valid cases where a programmer may want to wrap synchronous code in an asynchronous future: for example, spawning a synchronous task on an asynchronous scheduler, or implementing an async function for a trait where the implementation is synchronous. These cases are the reason this lint is pedantic. However, there are a few additional steps I want to take with this lint to avoid causing hassle or confusion for programmers:
async {}
block.Example
Could be written as:
Something like this, however, should not be caught by clippy:
The text was updated successfully, but these errors were encountered: