Skip to content

shadow_unrelated: entire match statement in warning instead of just var name #7764

Description

@matthiaskrgr

In cargo-cache I have code like this

            let split: Result<Vec<u32>, _> = date.split(':').map(str::parse).collect();
            let split = match split {
                Ok(result) => result,
                Err(a) => return Err(Error::DateParseFailure(a.to_string(), "u32".into())),
            };

And clippy put the entire match statement into the warning, seems a bit excessive..?

warning: `split` is shadowed by `match split {
                Ok(result) => result,
                Err(a) => return Err(Error::DateParseFailure(a.to_string(), "u32".into())),
            }` which reuses the original value
  --> src/date.rs:65:17
   |
65 |             let split = match split {
   |                 ^^^^^
   |
note: previous binding is here
  --> src/date.rs:64:17
   |
64 |             let split: Result<Vec<u32>, _> = date.split(':').map(str::parse).collect();
   |                 ^^^^^
   = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#shadow_reuse

clippy 0.1.57 (da3b4b459 2021-10-02)

Activity

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 thingL-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