Repository navigation
Fix enum constant pointer provenance during MIR import - #595
Merged
nihalpasham merged 2 commits intoJul 31, 2026
Merged
Conversation
Signed-off-by: Raul Estrada <[email protected]>
Collaborator
|
LGTM as-is. Verified on hardware:
Merging; closes #594. |
nihalpasham
approved these changes
Jul 31, 2026
5 tasks done
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.
Closes #594
Description
Summary
Preserve rustc pointer provenance while importing enum constants.
This changes enum constant translation to retain the enclosing allocation and its relocation map instead of decoding the enum exclusively from raw bytes.
Problem
Pointer-bearing constants are represented by rustc as allocation bytes plus relocation metadata. The bytes beneath a relocation contain only the pointer addend; they do not contain a complete exposed address.
The previous enum constant path did not retain this provenance information. As a result, it could not safely:
Nonecarrier;The existing negative example therefore rejected every enum constant containing pointer relocations.
Implementation
This PR:
u64conversion;Runtime regression
The former
error_enum_constant_provenancefixture is converted into the successfulenum_constant_provenanceruntime example.The example validates:
Option<&T>pointing at an interior device-static element;Noneniche variant;Expected output:
Unsupported cases
This PR intentionally does not add support for:
These cases continue to fail closed.
Validation
The following checks pass:
Results:
mir-importer: 892 tests passed;mir-lower: 145 unit tests and 76 integration tests passed;