Skip to content

fix: Improve label on add_missing_match_arms assist#21920

Merged
ChayimFriedman2 merged 1 commit intorust-lang:masterfrom
Wilfred:claude/update-match-arms-message-2RJMd
Apr 9, 2026
Merged

fix: Improve label on add_missing_match_arms assist#21920
ChayimFriedman2 merged 1 commit intorust-lang:masterfrom
Wilfred:claude/update-match-arms-message-2RJMd

Conversation

@Wilfred
Copy link
Copy Markdown
Contributor

@Wilfred Wilfred commented Mar 31, 2026

"Fill match arms" is an extremely helpful assist, but the name is pretty opaque to new users (at least it was to me). We actually renamed the file in #10299 from fill_match_arms.rs to add_missing_match_arms.rs but the label hasn't changed from its original text in #733.

Instead, show "Add missing match arms" if there are multiple missing match arms, and show "Add missing match arm Foo::Bar" when there's only a single missing match arm.

Partially generated by Claude Opus.

@rustbot rustbot added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 31, 2026
return None;
}

let first = missing_pats.next();
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I prefer to have missing_pats: Vec<_> by collecting beforehand.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Funny, that's what my first attempt did! The other nice thing about collecting is that I can show the exact number of missing arms in the label.

My concern was that most assists are deliberately lazy, hence me trying to just consume a bit of the iterator. What do you think?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This allocates anyway, so it doesn't really matter IMO.

let first = missing_pats.next();
let label = match (&first, missing_pats.peek()) {
(Some((pat, false)), None) => format!("Add missing match arm `{pat}`"),
(Some((_, true)), None) => "Add missing match arm `_`".to_owned(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think this arm will never hit. Also we may filter hidden patterns (that we do after) before this.

"Fill match arms" is an extremely helpful assist, but the name is
pretty opaque to new users (at least it was to me). We actually
renamed the file in rust-lang#10299 from
`fill_match_arms.rs` to `add_missing_match_arms.rs` but the label
hasn't changed from its original text in rust-lang#733.

Instead, show "Add N missing match arms" if there are multiple missing
match arms, and show "Add missing match arm `Foo::Bar`" when there's
only a single missing match arm.

Partially generated by Claude Opus.
@Wilfred Wilfred force-pushed the claude/update-match-arms-message-2RJMd branch from 2c9d993 to fd92d9d Compare April 7, 2026 12:30
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 7, 2026

This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@Wilfred
Copy link
Copy Markdown
Contributor Author

Wilfred commented Apr 7, 2026

Rebased, changed to use .collect() and show the exact number of missing arms, added test for the catch-all case.

Copy link
Copy Markdown
Contributor

@ChayimFriedman2 ChayimFriedman2 left a comment

Choose a reason for hiding this comment

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

@ChayimFriedman2 ChayimFriedman2 added this pull request to the merge queue Apr 9, 2026
Merged via the queue into rust-lang:master with commit 76ce53a Apr 9, 2026
31 of 33 checks passed
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 9, 2026
@Wilfred Wilfred deleted the claude/update-match-arms-message-2RJMd branch April 10, 2026 16:58
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.

3 participants