Skip to content

Commit 1da0071

Browse files
authored
Rollup merge of rust-lang#90102 - nbdd0121:box3, r=jonas-schievink
Remove `NullOp::Box` Follow up of rust-lang#89030 and MCP rust-lang/compiler-team#460. ~1 month later nothing seems to be broken, apart from a small regression that rust-lang#89332 (1aac85bb716c09304b313d69d30d74fe7e8e1a8e) shows could be regained by remvoing the diverging path, so it shall be safe to continue and remove `NullOp::Box` completely. r? `@jonas-schievink` `@rustbot` label T-compiler
2 parents a5a1425 + 0ef1158 commit 1da0071

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
@@ -715,30 +715,6 @@ fn codegen_stmt<'tcx>(
715715
let operand = operand.load_scalar(fx);
716716
lval.write_cvalue(fx, CValue::by_val(operand, box_layout));
717717
}
718-
Rvalue::NullaryOp(NullOp::Box, content_ty) => {
719-
let usize_type = fx.clif_type(fx.tcx.types.usize).unwrap();
720-
let content_ty = fx.monomorphize(content_ty);
721-
let layout = fx.layout_of(content_ty);
722-
let llsize = fx.bcx.ins().iconst(usize_type, layout.size.bytes() as i64);
723-
let llalign = fx.bcx.ins().iconst(usize_type, layout.align.abi.bytes() as i64);
724-
let box_layout = fx.layout_of(fx.tcx.mk_box(content_ty));
725-
726-
// Allocate space:
727-
let def_id =
728-
match fx.tcx.lang_items().require(rustc_hir::LangItem::ExchangeMalloc) {
729-
Ok(id) => id,
730-
Err(s) => {
731-
fx.tcx
732-
.sess
733-
.fatal(&format!("allocation of `{}` {}", box_layout.ty, s));
734-
}
735-
};
736-
let instance = ty::Instance::mono(fx.tcx, def_id).polymorphize(fx.tcx);
737-
let func_ref = fx.get_function_ref(instance);
738-
let call = fx.bcx.ins().call(func_ref, &[llsize, llalign]);
739-
let ptr = fx.bcx.inst_results(call)[0];
740-
lval.write_cvalue(fx, CValue::by_val(ptr, box_layout));
741-
}
742718
Rvalue::NullaryOp(null_op, ty) => {
743719
assert!(
744720
lval.layout()
@@ -749,7 +725,6 @@ fn codegen_stmt<'tcx>(
749725
let val = match null_op {
750726
NullOp::SizeOf => layout.size.bytes(),
751727
NullOp::AlignOf => layout.align.abi.bytes(),
752-
NullOp::Box => unreachable!(),
753728
};
754729
let val = CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), val.into());
755730
lval.write_cvalue(fx, val);

0 commit comments

Comments
 (0)