Skip to content

Needless Return at the end of function inside a closure suggests invalid code #6501

@fee1-dead

Description

@fee1-dead

This code:

fn foo(bar: Result<(), ()>) {
    bar.unwrap_or_else(|_| return)
}

is suggested to remove the return, like this:

fn foo(bar: Result<(), ()>) {
    bar.unwrap_or_else(|_| )
}

Which is invalid rust code.

Meta

  • cargo clippy -V: clippy 0.0.212 (bb1fbbf 2020-12-22)
  • rustc -Vv:
rustc 1.50.0-nightly (bb1fbbf84 2020-12-22)
binary: rustc
commit-hash: bb1fbbf84455fbad9afd26c17e0f725019322655
commit-date: 2020-12-22
host: x86_64-unknown-linux-gnu
release: 1.50.0-nightly

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 haveI-suggestion-causes-errorIssue: The suggestions provided by this Lint cause an ICE/error when applied

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions