Skip to content

Commit 7ac6cc9

Browse files
committed
Auto merge of #108442 - scottmcm:mir-transmute, r=oli-obk
Add `CastKind::Transmute` to MIR ~~Nothing actually produces it in this commit, so I don't know how to test it, but it also means it shouldn't be possible for it to break anything.~~ Includes lowering `transmute` calls to it, so it's used. Zulip Conversation: <https://rust-lang.zulipchat.com/#narrow/stream/189540-t-compiler.2Fwg-mir-opt/topic/Good.20first.20isssue/near/321849610>
2 parents 60aafee + 9558e12 commit 7ac6cc9

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)