Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
matthiaskrgr opened this issue Oct 4, 2021 · 2 comments · Fixed by #7782
Closed

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

matthiaskrgr opened this issue Oct 4, 2021 · 2 comments · Fixed by #7782
Labels
C-bug Category: Clippy is not doing the correct thing L-suggestion Lint: Improving, adding or fixing lint suggestions

Comments

@matthiaskrgr
Copy link
Member

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)

@matthiaskrgr matthiaskrgr added C-bug Category: Clippy is not doing the correct thing L-suggestion Lint: Improving, adding or fixing lint suggestions labels Oct 4, 2021
@matthiaskrgr
Copy link
Member Author

cc @camsteffen ?

@camsteffen
Copy link
Contributor

I believe this aspect of the lint is unchanged with #7338. I'd be fine with making it less verbose.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: Clippy is not doing the correct thing L-suggestion Lint: Improving, adding or fixing lint suggestions
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants