Skip to content

Commit 9dd0653

Browse files
committed
offset_of
1 parent fe3e383 commit 9dd0653

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

src/base.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -781,12 +781,15 @@ fn codegen_stmt<'tcx>(
781781
let operand = operand.load_scalar(fx);
782782
lval.write_cvalue(fx, CValue::by_val(operand, box_layout));
783783
}
784-
Rvalue::NullaryOp(null_op, ty) => {
784+
Rvalue::NullaryOp(ref null_op, ty) => {
785785
assert!(lval.layout().ty.is_sized(fx.tcx, ParamEnv::reveal_all()));
786786
let layout = fx.layout_of(fx.monomorphize(ty));
787787
let val = match null_op {
788788
NullOp::SizeOf => layout.size.bytes(),
789789
NullOp::AlignOf => layout.align.abi.bytes(),
790+
NullOp::OffsetOf(fields) => {
791+
layout.offset_of_subfield(fx, fields.iter().map(|f| f.index())).bytes()
792+
}
790793
};
791794
let val = CValue::const_val(fx, fx.layout_of(fx.tcx.types.usize), val.into());
792795
lval.write_cvalue(fx, val);

0 commit comments

Comments
 (0)