2540070fd4
Documents that `BikeshedIntrinsicFrom` models transmute-via-union, which is slightly more expressive than the transmute-via-cast implemented by `transmute_copy`. Additionally, we provide an implementation of transmute-via-union as a method on the `BikeshedIntrinsicFrom` trait with additional documentation on the boundary between trait invariants and caller obligations. Whether or not transmute-via-union is the right kind of transmute to model remains up for discussion [1]. Regardless, it seems wise to document the present behavior. [1] https://rust-lang.zulipchat.com/#narrow/stream/216762-project-safe-transmute/topic/What.20'kind'.20of.20transmute.20to.20model.3F/near/426331967
50 lines
1.2 KiB
Rust
50 lines
1.2 KiB
Rust
// MIR for `main` after built
|
|
|
|
| User Type Annotations
|
|
| 0: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_72181_1.rs:17:12: 17:16, inferred_ty: Void
|
|
| 1: user_ty: Canonical { value: Ty(Void), max_universe: U0, variables: [], defining_opaque_types: [] }, span: $DIR/issue_72181_1.rs:17:12: 17:16, inferred_ty: Void
|
|
|
|
|
fn main() -> () {
|
|
let mut _0: ();
|
|
let mut _1: !;
|
|
let _2: Void as UserTypeProjection { base: UserType(0), projs: [] };
|
|
let mut _3: ();
|
|
let _4: !;
|
|
let mut _5: Void;
|
|
scope 1 {
|
|
debug v => _2;
|
|
}
|
|
|
|
bb0: {
|
|
StorageLive(_2);
|
|
StorageLive(_3);
|
|
_3 = ();
|
|
_2 = std::intrinsics::transmute::<(), Void>(move _3) -> bb4;
|
|
}
|
|
|
|
bb1: {
|
|
StorageDead(_3);
|
|
FakeRead(ForLet(None), _2);
|
|
AscribeUserType(_2, o, UserTypeProjection { base: UserType(1), projs: [] });
|
|
StorageLive(_4);
|
|
StorageLive(_5);
|
|
_5 = move _2;
|
|
_4 = f(move _5) -> bb4;
|
|
}
|
|
|
|
bb2: {
|
|
StorageDead(_5);
|
|
StorageDead(_4);
|
|
StorageDead(_2);
|
|
unreachable;
|
|
}
|
|
|
|
bb3: {
|
|
return;
|
|
}
|
|
|
|
bb4 (cleanup): {
|
|
resume;
|
|
}
|
|
}
|