Skip to content

clippy: fix collapsible_match lint#1099

Merged
phimuemue merged 2 commits intorust-itertools:masterfrom
xtqqczze:clippy/collapsible_match
Apr 16, 2026
Merged

clippy: fix collapsible_match lint#1099
phimuemue merged 2 commits intorust-itertools:masterfrom
xtqqczze:clippy/collapsible_match

Conversation

@xtqqczze
Copy link
Copy Markdown
Contributor

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 15, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.92%. Comparing base (6814180) to head (348e1ba).
⚠️ Report is 187 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1099      +/-   ##
==========================================
- Coverage   94.38%   93.92%   -0.47%     
==========================================
  Files          48       51       +3     
  Lines        6665     6466     -199     
==========================================
- Hits         6291     6073     -218     
- Misses        374      393      +19     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@xtqqczze
Copy link
Copy Markdown
Contributor Author

xtqqczze commented Apr 15, 2026

I fixed this manually because the Clippy suggestion introduced an error; issue reported: rust-lang/rust-clippy#16860.

@phimuemue
Copy link
Copy Markdown
Member

phimuemue commented Apr 16, 2026

Hi there, thanks for this, but oh Clippy...

@jswrenn I think we should avoid _-wildcard-patterns in match unless strictly necessary. They don't show the possible states explicitly. I'd even discourage them with Option/Result/other similarly well-known types (if only for consistency). Same applies to matches!/if let in my book.

My guideline for reasonably explicit code would be:

  • No wildcards in match unless absolutely necessary. (Not even for simple types for consistency.)
  • No matches!.
  • Allow if let for Option.

imho we should bring our code to these standards, and - if Clippy complains too loudly - silence this particular lint.

@xtqqczze
Copy link
Copy Markdown
Contributor Author

In these cases, we could replace the match with a single if let guard, e.g.:

            if let Some(old_key) = self.current_key.take() {
                if old_key != key {
                    self.current_key = Some(key);
                    first_elt = Some(elt);
                    break;
                }
            }

@phimuemue
Copy link
Copy Markdown
Member

In these cases, we could replace the match with a single if let guard, e.g.:

Yes, please go with that.

Copy link
Copy Markdown
Member

@phimuemue phimuemue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@phimuemue phimuemue added this pull request to the merge queue Apr 16, 2026
Merged via the queue into rust-itertools:master with commit b1f0ba1 Apr 16, 2026
12 of 14 checks passed
@xtqqczze xtqqczze deleted the clippy/collapsible_match branch April 16, 2026 12:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants