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

match_wild_err_arm triggers weirdly #5024

Closed
Lokathor opened this issue Jan 8, 2020 · 2 comments · Fixed by #5034
Closed

match_wild_err_arm triggers weirdly #5024

Lokathor opened this issue Jan 8, 2020 · 2 comments · Fixed by #5034
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy

Comments

@Lokathor
Copy link

Lokathor commented Jan 8, 2020

If you match on Err(_) then it triggers the match_wild_err_arm lint and clippy tells you to match on each error individually, but if you match on Err(_e) it doesn't trigger at all, even though that's ignoring all possible errors just the same.

Code that brought this up

  #[inline]
  #[must_use]
  pub fn from_array_len(data: A, len: usize) -> Self {
    match Self::try_from_array_len(data, len) {
      Ok(out) => out,
      Err(_) => {
        panic!("ArrayishVec: length {} exceeds capacity {}!", len, A::CAPACITY)
      }
    }
  }
  • This should probably only trigger on enum errors, not struct errors.
  • Using a name other than _ will still match on everything, which is what this lint theoretically doesn't link, so alternate names should also still trigger the lint
@JohnTitor JohnTitor added the C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages label Jan 9, 2020
@JohnTitor
Copy link
Member

Actually, the lint description says it checks for arm which matches all errors with Err(_) so the identifiers like _e seem unintended.
But it might be nice that this lint also checks the identifiers which have _ as a prefix.

@flip1995
Copy link
Member

flip1995 commented Jan 9, 2020

We rarely have issues demanding that a lint should lint more, so I like this 😄

When linting on _e and similar, a check is required, that _e isn't used in the match arm though.

@flip1995 flip1995 added the good-first-issue These issues are a good way to get started with Clippy label Jan 9, 2020
@bors bors closed this as completed in be09bb4 Jan 15, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Enhancement of lints, like adding more cases or adding help messages good-first-issue These issues are a good way to get started with Clippy
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants