Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

needless_return does not lint on async function #7042

Closed
minseongg opened this issue Apr 6, 2021 · 1 comment · Fixed by #7067
Closed

needless_return does not lint on async function #7042

minseongg opened this issue Apr 6, 2021 · 1 comment · Fixed by #7067
Assignees
Labels
C-bug Category: Clippy is not doing the correct thing E-medium Call for participation: Medium difficulty level problem and requires some initial experience. I-false-negative Issue: The lint should have been triggered on code, but wasn't T-async-await Type: Issues related to async/await

Comments

@minseongg
Copy link

minseongg commented Apr 6, 2021

Clippy produces a false negative on a needless_return when there is an unneeded return statement in async function.
This is happening on both stable and nightly rust

I tried this code:

async fn test() -> Result<(), ()> {
    return Ok(());
}

fn main() -> Result<(), ()> {
    futures::executor::block_on(test())
}

I expected to have Clippy inform me about having an unneeded return, with this warning.

warning: unneeded `return` statement
 --> src/main.rs:2:5
  |
2 |     return Ok(());
  |     ^^^^^^^^^^^^^^ help: remove `return`: `Ok(())`
  |
  = note: `#[warn(clippy::needless_return)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return

Instead, this happened:

    Finished dev [unoptimized + debuginfo] target(s) in 0.10s

Meta

  • cargo clippy -V: clippy 0.1.52 (07e0e2ec 2021-03-24)
  • rustc -Vv:
rustc 1.53.0-nightly (07e0e2ec2 2021-03-24)
binary: rustc
commit-hash: 07e0e2ec268c140e607e1ac7f49f145612d0f597
commit-date: 2021-03-24
host: x86_64-apple-darwin
release: 1.53.0-nightly
LLVM version: 12.0.0
@minseongg minseongg added C-bug Category: Clippy is not doing the correct thing I-false-negative Issue: The lint should have been triggered on code, but wasn't labels Apr 6, 2021
@giraffate giraffate added E-medium Call for participation: Medium difficulty level problem and requires some initial experience. T-async-await Type: Issues related to async/await labels Apr 8, 2021
@TaKO8Ki
Copy link
Member

TaKO8Ki commented Apr 12, 2021

@rustbot claim

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing E-medium Call for participation: Medium difficulty level problem and requires some initial experience. I-false-negative Issue: The lint should have been triggered on code, but wasn't T-async-await Type: Issues related to async/await
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants