Skip to content

Commit 9558e12

Browse files
committed
Add CastKind::Transmute to MIR
Updates `interpret`, `codegen_ssa`, and `codegen_cranelift` to consume the new cast instead of the intrinsic. Includes `CastTransmute` for custom MIR building, to be able to test the extra UB.
1 parent edb0717 commit 9558e12

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

src/base.rs

+4
Original file line numberDiff line numberDiff line change
@@ -709,6 +709,10 @@ fn codegen_stmt<'tcx>(
709709
let operand = codegen_operand(fx, operand);
710710
operand.coerce_dyn_star(fx, lval);
711711
}
712+
Rvalue::Cast(CastKind::Transmute, ref operand, _to_ty) => {
713+
let operand = codegen_operand(fx, operand);
714+
lval.write_cvalue_transmute(fx, operand);
715+
}
712716
Rvalue::Discriminant(place) => {
713717
let place = codegen_place(fx, place);
714718
let value = place.to_cvalue(fx);

src/intrinsics/mod.rs

-10
Original file line numberDiff line numberDiff line change
@@ -557,16 +557,6 @@ fn codegen_regular_intrinsic_call<'tcx>(
557557
fx.bcx.ins().band(ptr, mask);
558558
}
559559

560-
sym::transmute => {
561-
intrinsic_args!(fx, args => (from); intrinsic);
562-
563-
if ret.layout().abi.is_uninhabited() {
564-
crate::base::codegen_panic(fx, "Transmuting to uninhabited type.", source_info);
565-
return;
566-
}
567-
568-
ret.write_cvalue_transmute(fx, from);
569-
}
570560
sym::write_bytes | sym::volatile_set_memory => {
571561
intrinsic_args!(fx, args => (dst, val, count); intrinsic);
572562
let val = val.load_scalar(fx);

0 commit comments

Comments
 (0)