Skip to content

Fix incorrect let to const suggestion for pattern bindings#152834

Open
lapla-cogito wants to merge 1 commit intorust-lang:mainfrom
lapla-cogito:issue_152831
Open

Fix incorrect let to const suggestion for pattern bindings#152834
lapla-cogito wants to merge 1 commit intorust-lang:mainfrom
lapla-cogito:issue_152831

Conversation

@lapla-cogito
Copy link
Contributor

@lapla-cogito lapla-cogito commented Feb 19, 2026

When a variable from a pattern binding was referenced inside a const {} block, the compiler incorrectly suggested replacing let with const. This was reported in #152831 for if let, but also applies to while let and let ... else.

close #152831

@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 19, 2026
@rustbot
Copy link
Collaborator

rustbot commented Feb 19, 2026

r? @jackh726

rustbot has assigned @jackh726.
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 15 candidates

@rust-log-analyzer

This comment has been minimized.

@@ -1,3 +1,4 @@
// ignore-tidy-filelength
Copy link
Member

Choose a reason for hiding this comment

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

why was this introduced?

Copy link
Contributor Author

@lapla-cogito lapla-cogito Feb 19, 2026

Choose a reason for hiding this comment

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

The tidy test would fail without it (see the comment above by rust-log-analyzer). Since this directive is already used in other files, I didn’t think it would be an issue to use it here as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If splitting the commit is more appropriate, I'll do so.

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. 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.

Incorrect diagnostic for if-let-guard + attempting to use a non-constant value in a constant

5 participants