Skip to content

match_wild_err_arm triggers weirdly #5024

Closed
@Lokathor

Description

@Lokathor

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: Enhancement of lints, like adding more cases or adding help messagesgood 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