Skip to content

False positive with redundant_closure #4354

@LunaBorowska

Description

@LunaBorowska

Not sure if it's not a duplicate of some issue, there are a lot of tickets, but this still seems distinct. Tested both on nightly and stable.

~/k/pastebinrun (master|✔) $ cargo clippy -V
clippy 0.0.212 (082cfa7 2019-06-07)
~/k/pastebinrun (master|✔) $ cargo +nightly clippy -V
clippy 0.0.212 (b041511 2019-08-07)

Sample code:

fn callbacker(_: impl Fn(&mut [u8])) {}
fn g<W>(_: W) {}
fn main() {
    callbacker(|w| g(w));
}

Causes the following warning.

    Checking playground v0.0.1 (/playground)
warning: redundant closure found
 --> src/main.rs:4:16
  |
4 |     callbacker(|w| g(w));
  |                ^^^^^^^^ help: remove closure as shown: `g`
  |
  = note: `#[warn(clippy::redundant_closure)]` on by default
  = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#redundant_closure

The closure cannot be removed as shown.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-bugCategory: Clippy is not doing the correct thingI-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