Skip to content

Fix incorrect let to const suggestion for pattern bindings#152834

Merged
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
lapla-cogito:issue_152831
Apr 22, 2026
Merged

Fix incorrect let to const suggestion for pattern bindings#152834
rust-bors[bot] merged 2 commits intorust-lang:mainfrom
lapla-cogito:issue_152831

Conversation

@lapla-cogito
Copy link
Copy Markdown
Contributor

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

View all comments

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.

@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
Copy Markdown
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.

Comment thread compiler/rustc_resolve/src/diagnostics.rs
@lapla-cogito
Copy link
Copy Markdown
Contributor Author

Friendly ping @jackh726

Comment thread compiler/rustc_resolve/src/diagnostics.rs Outdated
Comment thread compiler/rustc_resolve/src/diagnostics.rs
@rustbot rustbot removed the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Apr 12, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 12, 2026

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

@rustbot rustbot added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Apr 12, 2026
@rustbot

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@lapla-cogito
Copy link
Copy Markdown
Contributor Author

@rustbot ready

@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 Apr 13, 2026
Copy link
Copy Markdown
Member

@jackh726 jackh726 left a comment

Choose a reason for hiding this comment

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

The tests aren't really in the right place. I don't know exactly the right place, but these are inline-const as much as like "using non-const local in const"

View changes since this review

Comment thread tests/ui/inline-const/pat-binding-irrefutable-non-const.rs Outdated
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented Apr 21, 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.

@lapla-cogito
Copy link
Copy Markdown
Contributor Author

The tests aren't really in the right place. I don't know exactly the right place, but these are inline-const as much as like "using non-const local in const"

Moved tests to tests/ui/consts/ to position them more neutrally.

@jackh726
Copy link
Copy Markdown
Member

@bors r+ rollup

@rust-bors
Copy link
Copy Markdown
Contributor

rust-bors Bot commented Apr 21, 2026

📌 Commit 90c03d8 has been approved by jackh726

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 Apr 21, 2026
rust-bors Bot pushed a commit that referenced this pull request Apr 21, 2026
…uwer

Rollup of 5 pull requests

Successful merges:

 - #155546 (Improve E0308 error message for `impl Trait` return mismatches)
 - #152834 (Fix incorrect `let` to `const` suggestion for pattern bindings)
 - #155425 (Remove duplicated `Flags` methods.)
 - #155547 (Use per-parent disambiguators everywhere)
 - #155590 (Remove AttributeLintKind variants - part 5)
@rust-bors rust-bors Bot merged commit 65fcd87 into rust-lang:main Apr 22, 2026
11 checks passed
@rustbot rustbot added this to the 1.97.0 milestone Apr 22, 2026
@lapla-cogito lapla-cogito deleted the issue_152831 branch April 22, 2026 03:03
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.

5 participants