1
Fork 0

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
This commit is contained in:
许杰友 Jieyou Xu (Joe) 2025-03-16 13:19:53 +08:00 committed by GitHub
commit e714c3be9f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View file

@ -747,7 +747,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
let tcx = self.cx.tcx(); let tcx = self.cx.tcx();
OperandRef { OperandRef {
val: OperandValue::Immediate(val), val: OperandValue::Immediate(val),
layout: self.cx.layout_of(tcx.types.usize), layout: self.cx.layout_of(null_op.ty(tcx)),
} }
} }

View file

@ -774,6 +774,15 @@ impl BorrowKind {
} }
} }
impl<'tcx> NullOp<'tcx> {
pub fn ty(&self, tcx: TyCtxt<'tcx>) -> Ty<'tcx> {
match self {
NullOp::SizeOf | NullOp::AlignOf | NullOp::OffsetOf(_) => tcx.types.usize,
NullOp::UbChecks | NullOp::ContractChecks => tcx.types.bool,
}
}
}
impl<'tcx> UnOp { impl<'tcx> UnOp {
pub fn ty(&self, tcx: TyCtxt<'tcx>, arg_ty: Ty<'tcx>) -> Ty<'tcx> { pub fn ty(&self, tcx: TyCtxt<'tcx>, arg_ty: Ty<'tcx>) -> Ty<'tcx> {
match self { match self {