Skip to content

Commit e714c3b

Browse files
authored
Rollup merge of #138549 - scottmcm:option-ssa, r=saethlin
Fix the OperandRef type for NullOp::{UbChecks,ContractChecks} Stumbled on this while looking at something totally unrelated 🙃 r? saethlin
2 parents c29a29e + 3d42541 commit e714c3b

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

Diff for: compiler/rustc_codegen_ssa/src/mir/rvalue.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
747747
let tcx = self.cx.tcx();
748748
OperandRef {
749749
val: OperandValue::Immediate(val),
750-
layout: self.cx.layout_of(tcx.types.usize),
750+
layout: self.cx.layout_of(null_op.ty(tcx)),
751751
}
752752
}
753753

Diff for: compiler/rustc_middle/src/mir/statement.rs

+9
Original file line numberDiff line numberDiff line change
@@ -774,6 +774,15 @@ impl BorrowKind {
774774
}
775775
}
776776

777+
impl<'tcx> NullOp<'tcx> {
778+
pub fn ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
779+
match self {
780+
NullOp::SizeOf | NullOp::AlignOf | NullOp::OffsetOf(_) => tcx.types.usize,
781+
NullOp::UbChecks | NullOp::ContractChecks => tcx.types.bool,
782+
}
783+
}
784+
}
785+
777786
impl<'tcx> UnOp {
778787
pub fn ty(&self, tcx: TyCtxt<'tcx>, arg_ty: Ty<'tcx>) -> Ty<'tcx> {
779788
match self {

0 commit comments

Comments
 (0)