7

Github New lint: `unused_async` by InquisitivePenguin · Pull Request #7225 · rus...

 3 years ago
source link: https://github.com/rust-lang/rust-clippy/pull/7225
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

changelog: Adds a lint, unused_async, which checks for async functions with no await statements

unused_async is a lint that reduces code smell and overhead by encouraging async functions to be refactored into synchronous functions.

Fixes #7176

Examples

async fn get_random_number() -> i64 {
    4 // Chosen by fair dice roll. Guaranteed to be random.
}

Could be written as:

fn get_random_number() -> i64 {
    4 // Chosen by fair dice roll. Guaranteed to be random.
}

Something like this, however, should not be caught by clippy:

#[async_trait]
trait AsyncTrait {
    async fn foo();
}

struct Bar;

#[async_trait]
impl AsyncTrait for Bar {
    async fn foo() {
        println!("bar");
    }
}

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK