Skip to content

False needless_return trigger + invalid suggestion #13486

Closed
@zeenix

Description

@zeenix

Summary

With the latest nightly clippy, I'm getting a false positive and to make things worse, the recommendation isn't valid Rust code:

error: unneeded `return` statement
   --> src/bin/busd.rs:112:7
    |
112 |     Ok(())
    |       ^^^^
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_return
    = note: `-D clippy::needless-return` implied by `-D warnings`
    = help: to override `-D warnings` add `#[allow(clippy::needless_return)]`
help: remove `return`
    |
112 ~     Okif let Err(e) = bus.cleanup().await {
113 +         error!("Failed to clean up: {}", e);
114 +     }
115 + 
116 +     Ok(())
    |

Lint Name

needless_return

Reproducer

https://github.com/dbus2/busd/blob/3a8ed5785f1c17e4adf7892155779b7c24444496/src/bin/busd.rs#L108

Version

rustc 1.81.0 (eeb90cda1 2024-09-04)
binary: rustc
commit-hash: eeb90cda1969383f56a2637cbd3037bdf598841c
commit-date: 2024-09-04
host: x86_64-unknown-linux-gnu
release: 1.81.0
LLVM version: 18.1.7

Additional Labels

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't have

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions