Skip to content

clippy::redundant_closure false positive: laziness #4187

Closed
@projedi

Description

@projedi

Clippy warns me about redundant closure:

warning: redundant closure found
   --> src/parser_lib.rs:291:14
    |
291 |     Box::new(move |s| pf()(s))
    |              ^^^^^^^^^^^^^^^^ help: remove closure as shown: `pf()`
    |
    = 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

But the suggested transformation changes semantics: the original code executes pf only when the closure is executed; the suggested code executes pf immediately.

> cargo clippy -V
clippy 0.0.212 (265318db 2019-05-17)

Metadata

Metadata

Assignees

No one assigned

    Labels

    L-suggestionLint: Improving, adding or fixing lint suggestionsgood first issueThese issues are a good way to get started with Clippy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions