Skip to content

Commit 0ef1158

Browse files
committed
Remove NullOp::Box
1 parent 44cce7a commit 0ef1158

File tree

1 file changed

+0
-25
lines changed

1 file changed

+0
-25
lines changed

src/base.rs

-25
Original file line numberDiff line numberDiff line change
@@ -708,30 +708,6 @@ fn codegen_stmt<'tcx>(
708708
let operand = operand.load_scalar(fx);
709709
lval.write_cvalue(fx, CValue::by_val(operand, box_layout));
710710
}
711-
Rvalue::NullaryOp(NullOp::Box, content_ty) => {
712-
let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap();
713-
let content_ty = fx.monomorphize(content_ty);
714-
let layout = fx.layout_of(content_ty);
715-
let llsize = fx.bcx.ins().iconst(usize_type, layout.size.bytes() as i64);
716-
let llalign = fx.bcx.ins().iconst(usize_type, layout.align.abi.bytes() as i64);
717-
let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty));
718-
719-
// Allocate space:
720-
let def_id =
721-
match fx.tcx.lang_items().require(rustc_hir::LangItem::ExchangeMalloc) {
722-
Ok(id) => id,
723-
Err(s) => {
724-
fx.tcx
725-
.sess
726-
.fatal(&format!("allocation of `{}` {}", box_layout.ty, s));
727-
}
728-
};
729-
let instance = ty::Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx);
730-
let func_ref = fx.get_function_ref(instance);
731-
let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]);
732-
let ptr = fx.bcx.inst_results(call)[0];
733-
lval.write_cvalue(fx, CValue::by_val(ptr, box_layout));
734-
}
735711
Rvalue::NullaryOp(null_op, ty) => {
736712
assert!(
737713
lval.layout()
@@ -742,7 +718,6 @@ fn codegen_stmt<'tcx>(
742718
let val = match null_op {
743719
NullOp::SizeOf => layout.size.bytes(),
744720
NullOp::AlignOf => layout.align.abi.bytes(),
745-
NullOp::Box => unreachable!(),
746721
};
747722
let val =
748723
CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), val.into());

0 commit comments

Comments
 (0)