fix: Don't support const blocks in patterns - #23307
Merged
ChayimFriedman2 merged 1 commit intoSep 9, 2026
Merged
Conversation
Contributor
|
If rustc removed const patterns (and as far ago as more than a year), we should also remove them. |
Support for const blocks in pattern positions was removed from rustc in rust-lang/rust@a9442b4 Remove Pat::ConstBlock from hir-def so rust-analyzer is consistent with rustc lowering. This also fixes a panic on closure calls in const blocks. This occurred because we ended up running type inference twice on ConstBlock in some code paths. AI disclosure: Code partly written by GPT-5.6, commit message and review by me.
Wilfred
force-pushed
the
fix/const-block-double-infer
branch
from
September 9, 2026 11:34
9b82ba3 to
9d3d1f9
Compare
Collaborator
|
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. |
Contributor
Author
|
OK, I've removed the support for const blocks in lowering, matching rustc. I just dropped the relevant tests, it seemed pointless having tests for removed code paths. I did notice that we don't currently emit any diagnostics the way rustc does for this situation: This is already an improvement, fixing the panic I was originally looking at. Long term, do we want r-a to emit all the same diagnostics that rustc does? |
ChayimFriedman2
approved these changes
Sep 9, 2026
This was referenced Sep 9, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Support for const blocks in pattern positions was removed from rustc
in rust-lang/rust@a9442b4
Remove Pat::ConstBlock from hir-def so rust-analyzer is consistent with rustc lowering.
This also fixes a panic on closure calls in const blocks. This occurred because we ended up running type inference twice on ConstBlock in some code paths.
AI disclosure: Code partly written by GPT-5.6, commit message and review by me.