Skip to content

Improve irrefutable let-else lint wording#153048

Merged
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
ozankenangungor:fix-irrefutable-let-else-wording
Mar 4, 2026
Merged

Improve irrefutable let-else lint wording#153048
rust-bors[bot] merged 1 commit intorust-lang:mainfrom
ozankenangungor:fix-irrefutable-let-else-wording

Conversation

@ozankenangungor
Copy link
Contributor

@ozankenangungor ozankenangungor commented Feb 24, 2026

Update the irrefutable_let_patterns wording for let-else to better reflect that the else clause is unreachable when the LHS pattern always matches.

Closes #152938

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 24, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 24, 2026

r? @davidtwco

rustbot has assigned @davidtwco.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 68 candidates
  • Random selection from 14 candidates

@Kivooeo Kivooeo assigned Kivooeo and unassigned davidtwco Feb 24, 2026
@ozankenangungor ozankenangungor force-pushed the fix-irrefutable-let-else-wording branch from 1af1bc9 to 8f4b39f Compare February 24, 2026 18:39
@rustbot
Copy link
Collaborator

rustbot commented Feb 24, 2026

Some changes occurred in match checking

cc @Nadrieril

@ozankenangungor ozankenangungor force-pushed the fix-irrefutable-let-else-wording branch from 8f4b39f to 92c4925 Compare February 24, 2026 19:00
*[other] these patterns
} will always match, so the `else` clause is useless"
} will always succeed, so the `else` clause is unreachable"
)]
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we turn this into a span_label pointing at the pattern (in most cases, a binding)? It might even make sense to detect when it is an identifier binding to explain in a note that all let bindings are patterns.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good idea. Right now the primary span already points at the pattern, and I tried to keep the wording generic to avoid extra logic. I would prefer to keep this pr small, I can follow up separately if we want to explore a span label binding specific note.

@Kivooeo
Copy link
Member

Kivooeo commented Feb 25, 2026

I don't think that creating a new field just for this is reasonable, I think it would make more much sense to pass else_span as argument

@ozankenangungor ozankenangungor force-pushed the fix-irrefutable-let-else-wording branch from 92c4925 to eba9297 Compare February 26, 2026 08:29
@rustbot

This comment has been minimized.

@ozankenangungor
Copy link
Contributor Author

I don't think that creating a new field just for this is reasonable, I think it would make more much sense to pass else_span as argument

Thanks, that makes sense. I will switch this to pass else_span through as an argument instead of storing it on MatchVisitor.

@ozankenangungor ozankenangungor force-pushed the fix-irrefutable-let-else-wording branch from eba9297 to db88aa2 Compare February 26, 2026 10:46
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 28, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 28, 2026

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@ozankenangungor ozankenangungor force-pushed the fix-irrefutable-let-else-wording branch from db88aa2 to 906e74b Compare March 1, 2026 01:32
@rustbot

This comment has been minimized.

@ozankenangungor ozankenangungor requested a review from Kivooeo March 1, 2026 02:01
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Mar 1, 2026
@ozankenangungor
Copy link
Contributor Author

@rustbot ready

@ozankenangungor ozankenangungor force-pushed the fix-irrefutable-let-else-wording branch from 906e74b to a8d4eee Compare March 3, 2026 00:40
@rustbot
Copy link
Collaborator

rustbot commented Mar 3, 2026

This PR was rebased onto a different main 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.

Copy link
Member

@Kivooeo Kivooeo left a comment

Choose a reason for hiding this comment

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

nice! thanks for the effort you put into addressing all the feedback and going through multiple rounds of review

View changes since this review

@Kivooeo
Copy link
Member

Kivooeo commented Mar 3, 2026

@bors r+ rollup

@rust-bors
Copy link
Contributor

rust-bors bot commented Mar 3, 2026

📌 Commit a8d4eee has been approved by Kivooeo

It is now in the queue for this repository.

@rust-bors rust-bors bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Mar 3, 2026
rust-bors bot pushed a commit that referenced this pull request Mar 4, 2026
Rollup of 8 pull requests

Successful merges:

 - #153280 (Add regression test for `doc(fake_variadic)` on reexports)
 - #153302 (x86: reserve `bl` and `bh` registers to match `rbx`)
 - #153358 (Boundary tests for various Duration-float operations)
 - #153048 (Improve irrefutable let-else lint wording)
 - #153258 (diag: Suppress `.clone()` suggestion inside derive macro expansions)
 - #153272 (Add `Path::absolute` method as alias for `std::path::absolute`)
 - #153295 (update panicking() docs for panic=abort)
 - #153352 (Migration of `LintDiagnostic` - part 6)
@rust-bors rust-bors bot merged commit 70287b9 into rust-lang:main Mar 4, 2026
11 checks passed
@rustbot rustbot added this to the 1.96.0 milestone Mar 4, 2026
rust-timer added a commit that referenced this pull request Mar 4, 2026
Rollup merge of #153048 - ozankenangungor:fix-irrefutable-let-else-wording, r=Kivooeo

Improve irrefutable let-else lint wording

Update the `irrefutable_let_patterns` wording for let-else to better reflect that the `else` clause is unreachable when the LHS pattern always matches.

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

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Irrefutable pattern warning is confusing when pattern is on RHS

6 participants