Conversation
ChayimFriedman2
requested changes
Aug 18, 2026
Contributor
There was a problem hiding this comment.
This isn't the correct way to fix that. It should be fixed during MIR lowering, see the corresponding code in rustc: https://github.com/rust-lang/rust/blob/e71c0f1e3395b10a8c331317be1a5c107bdf7b2e/compiler/rustc_mir_build/src/builder/expr/as_rvalue.rs#L125-L163.
hlsxx
force-pushed
the
enum-dicr-evaluation
branch
from
August 28, 2026 16:44
6e61250 to
5627c1c
Compare
This comment has been minimized.
This comment has been minimized.
hlsxx
force-pushed
the
enum-dicr-evaluation
branch
3 times, most recently
from
August 29, 2026 10:37
b36d82e to
b32e18a
Compare
ChayimFriedman2
requested changes
Sep 2, 2026
hlsxx
force-pushed
the
enum-dicr-evaluation
branch
2 times, most recently
from
September 14, 2026 19:48
7314abf to
199e5d4
Compare
This comment has been minimized.
This comment has been minimized.
When an enum variant discriminant initializer references another variant via a cast, e.g. `B = Foo::A as isize + 1` the previous implementation would lower `Foo::A` as a place and then extract its discriminant via `Rvalue::Discriminant`. This caused infinite recursion during consteval because evaluating the discriminant of one variant requires evaluating another. # Conflicts: # crates/hir-ty/src/mir/lower.rs
hlsxx
force-pushed
the
enum-dicr-evaluation
branch
from
September 15, 2026 17:09
199e5d4 to
185846c
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. |
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.
Single-variant enum incorrectly evaluated to 0.
Previously enum-to-int casts were lowered as a plain
Rvalue::Cast, causing single-variant enums to evaluate to 0 instead of their corresponding discriminant value.Fixes enum discriminant handling in MIR lowering by extracting the discriminant before performing the integer cast. Prevents recursion in MIR evaluation by reading discriminant bytes directly when the owner is a variant of the same enum in
Rvalue::Discriminantbranch.Fixes #23148