Skip to content

clippy::redundant_closure suggestion unnecessarily complicated #3974

Open
@therealprof

Description

@therealprof

Clippy rightfully suggests to simplify a map with a as_str () in the closure to us as_str directly. However the given suggestion is a bit too complicated and verbose given that the String module is always imported:

warning: redundant closure found
   --> src/main.rs:317:30
    |
317 |         version.as_ref().map(|v| v.as_str()),
    |                              ^^^^^^^^^^^^^^ help: remove closure as shown: `std::string::String::as_str`
    |
    = 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

It would be gread if the lint would say:

^^^^^^^^^^^^^^ help:  remove closure as shown: `String::as_str`

instead.

The version is:

clippy 0.0.212 (1fac3808 2019-02-20)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesL-suggestionLint: Improving, adding or fixing lint suggestions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions