]> git.lizzy.rs Git - rust.git/commit
Auto merge of #7225 - InquisitivePenguin:unnessecary-async, r=llogiq
authorbors <bors@rust-lang.org>
Mon, 17 May 2021 06:00:55 +0000 (06:00 +0000)
committerbors <bors@rust-lang.org>
Mon, 17 May 2021 06:00:55 +0000 (06:00 +0000)
commitacdf43f2575d534893840091c6c0a19b861ab263
tree3d7521ce2a5242fef39a141112c56833d1961613
parent44e07476647ffb26f1aae034813a7ca430cb37b9
parent75ef9dc708e669bccbc18c3be4873c613058ef30
Auto merge of #7225 - InquisitivePenguin:unnessecary-async, r=llogiq

New lint: `unused_async`

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

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

Could be written as:

```rust
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:
```rust
#[async_trait]
trait AsyncTrait {
    async fn foo();
}

struct Bar;

#[async_trait]
impl AsyncTrait for Bar {
    async fn foo() {
        println!("bar");
    }
}
```
CHANGELOG.md
clippy_lints/src/lib.rs