Skip to content

False needless_return trigger + invalid suggestion #13486

@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

Activity

added
C-bugCategory: Clippy is not doing the correct thing
I-false-positiveIssue: The lint was triggered on code it shouldn't have
on Oct 1, 2024
y21

y21 commented on Oct 1, 2024

@y21
Member

Most likely a duplicate of #13458 (which will be fixed by #13464)

added a commit that references this issue on Oct 10, 2024
8e60f14
added a commit that references this issue on Oct 18, 2024
806a9df
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      Participants

      @zeenix@y21

      Issue actions

        False `needless_return` trigger + invalid suggestion · Issue #13486 · rust-lang/rust-clippy