Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 1b104c9

Browse files
authoredMar 16, 2025
Unrolled build for rust-lang#138549
Rollup merge of rust-lang#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 5f3b84a + 3d42541 commit 1b104c9

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed
 

‎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

‎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)
Failed to load comments.