Skip to content

Base fill-match-arms suggestions on the exhaustiveness checker - #23100

Open
rit3sh-x wants to merge 1 commit into
rust-lang:masterfrom
rit3sh-x:fix/8129-fill-match-arms-exhaustive
Open

Base fill-match-arms suggestions on the exhaustiveness checker#23100
rit3sh-x wants to merge 1 commit into
rust-lang:masterfrom
rit3sh-x:fix/8129-fill-match-arms-exhaustive

Conversation

@rit3sh-x

@rit3sh-x rit3sh-x commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

Fixes #8129.

What changed

  • add_missing_match_arms now asks the exhaustiveness checker for the patterns actually missing from a match (via a new missing_match_arm_patterns query added to hir-ty and exposed through Semantics), instead of only enumerating the scrutinee's top-level enum variants. This covers arms nested inside tuples, structs, references, and Option, and no longer produces the invalid catch-all rewrite from "Fill match arms" code action creates non-exhaustive match #8129 when a wildcard arm hides a real gap.
  • Falls back to the previous variant-enumeration behavior when the checker can't describe the gap concisely (bare wildcards, or a witness whose only content is a full tuple enumeration).
  • Added crates/hir-ty/src/diagnostics/expr.rs::UncoveredPattern<Var>, a generic witness-shape type shared between hir-ty (parameterized over VariantId) and hir (parameterized over Variant via map_variant), rather than two independent copies of the same enum.

Testing

  • New coverage in crates/ide-assists/src/handlers/add_missing_match_arms.rs exercising nested variants, record fields, or-patterns, guards, hidden variants, self-referential enums, and Self-qualified paths.

AI Usage

  • Used in generated test cases and comments.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 9, 2026
@ChayimFriedman2

Copy link
Copy Markdown
Contributor

It's sad that you worked on this since I already have a working branch (and I've said that multiple times).

Given that, if this is already in good shape, I'll merge this, but if not, I'll not engage in in review rounds and just close this.

Thank you for your interest in contribution anyway!

@rit3sh-x

rit3sh-x commented Aug 9, 2026

Copy link
Copy Markdown
Contributor Author

@ChayimFriedman2 bad timing is my forte 😅, feel free to address my issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"Fill match arms" code action creates non-exhaustive match

3 participants