Repository navigation
Conversation
Signed-off-by: Raul Estrada <[email protected]>
|
The direction is generally right, but this version breaks the compiler, so it can't merge. This needs a rethink deep enough that a fresh PR is the better route.
Suggested path: let's agree on the transition table in #413 first, then a new PR. The core question is where kind changes are allowed: explicit Also: drop "Fixes #413" from the description. #413 is a tracking issue; this covers the representation half only and stays open either way. |
|
Closing. Please see above. |
Summary
Preserve Rust pointer/reference kind through MIR import instead of collapsing
references and raw pointers that share the same pointee, mutability, and address
space.
Fixes #413.
This introduces
MirPointerKindwith the following categories:SharedReffor&TUniqueReffor&mut TRawConstfor*const TRawMutfor*mut TErasedfor compiler-generated/internal addressesThe kind is carried by both
MirPtrTypeandMirSliceType.What changed
dialect-mir
MirPointerKind.MirPtrType.MirSliceType.Erased.mutability bit.
MIR importer
Rust types now map as follows:
&TSharedRef&mut TUniqueRef*const TRawConst*mut TRawMutPointer kind is preserved through relevant importer paths, including:
Rvalue::RefRvalue::AddressOfCompiler-generated storage and temporary addresses remain
Erased.Pointer normalization is intentionally conservative. It may restore a concrete
Rust kind at an explicit Rust-typed semantic boundary, but generic coercion does
not silently convert one concrete Rust pointer category into another. For
example, it cannot synthesize:
SharedRef -> UniqueRefRawConst -> RawMutMIR lowering
MirPointerKindis semantic-only and is intentionally erased during MIR-to-LLVMtype conversion.
When a cast changes only MIR pointer kind and both sides lower to the same LLVM
type, lowering forwards the value directly instead of emitting an unnecessary
LLVM cast or memory round-trip.
This PR deliberately does not emit LLVM
noalias,readonly,dereferenceable, or related metadata.Retagremains a codegen no-op; dynamic Stacked Borrows / Tree Borrows state isoutside the scope of this change.
Tests
Added coverage for:
Validation performed:
All checks pass.