File tree Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Expand file tree Collapse file tree 2 files changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -726,15 +726,20 @@ fn codegen_stmt<'tcx>(
726726 let ptr = fx.bcx.inst_results(call)[0];
727727 lval.write_cvalue(fx, CValue::by_val(ptr, box_layout));
728728 }
729- Rvalue::NullaryOp(NullOp::SizeOf , ty) => {
729+ Rvalue::NullaryOp(null_op , ty) => {
730730 assert!(
731731 lval.layout()
732732 .ty
733733 .is_sized(fx.tcx.at(stmt.source_info.span), ParamEnv::reveal_all())
734734 );
735- let ty_size = fx.layout_of(fx.monomorphize(ty)).size.bytes();
735+ let layout = fx.layout_of(fx.monomorphize(ty));
736+ let val = match null_op {
737+ NullOp::SizeOf => layout.size.bytes(),
738+ NullOp::AlignOf => layout.align.abi.bytes(),
739+ NullOp::Box => unreachable!(),
740+ };
736741 let val =
737- CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), ty_size .into());
742+ CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), val .into());
738743 lval.write_cvalue(fx, val);
739744 }
740745 Rvalue::Aggregate(ref kind, ref operands) => match kind.as_ref() {
Original file line number Diff line number Diff line change @@ -823,7 +823,7 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
823823 dest.write_cvalue(fx, val);
824824 };
825825
826- pref_align_of | min_align_of | needs_drop | type_id | type_name | variant_count, () {
826+ pref_align_of | needs_drop | type_id | type_name | variant_count, () {
827827 let const_val =
828828 fx.tcx.const_eval_instance(ParamEnv::reveal_all(), instance, None).unwrap();
829829 let val = crate::constant::codegen_const_value(
You can’t perform that action at this time.
0 commit comments