Skip to content

Commit a0de5ae

Browse files
committed
Replace Rvalue::NullaryOp by a variant in mir::ConstValue.
1 parent 9561346 commit a0de5ae

2 files changed

Lines changed: 6 additions & 12 deletions

File tree

src/base.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_data_structures::profiling::SelfProfilerRef;
1010
use rustc_index::IndexVec;
1111
use rustc_middle::ty::TypeVisitableExt;
1212
use rustc_middle::ty::adjustment::PointerCoercion;
13-
use rustc_middle::ty::layout::{FnAbiOf, HasTypingEnv};
13+
use rustc_middle::ty::layout::FnAbiOf;
1414
use rustc_middle::ty::print::with_no_trimmed_paths;
1515
use rustc_session::config::OutputFilenames;
1616
use rustc_span::Symbol;
@@ -853,17 +853,6 @@ fn codegen_stmt<'tcx>(fx: &mut FunctionCx<'_, '_, 'tcx>, cur_block: Block, stmt:
853853
fx.bcx.ins().nop();
854854
}
855855
}
856-
Rvalue::NullaryOp(ref null_op) => {
857-
assert!(lval.layout().ty.is_sized(fx.tcx, fx.typing_env()));
858-
let val = match null_op {
859-
NullOp::RuntimeChecks(kind) => kind.value(fx.tcx.sess),
860-
};
861-
let val = CValue::by_val(
862-
fx.bcx.ins().iconst(types::I8, i64::from(val)),
863-
fx.layout_of(fx.tcx.types.bool),
864-
);
865-
lval.write_cvalue(fx, val);
866-
}
867856
Rvalue::Aggregate(ref kind, ref operands)
868857
if matches!(**kind, AggregateKind::RawPtr(..)) =>
869858
{

src/constant.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,11 @@ pub(crate) fn codegen_const_value<'tcx>(
215215
CValue::by_val(val, layout)
216216
}
217217
},
218+
ConstValue::RuntimeChecks(checks) => {
219+
let int = checks.value(fx.tcx.sess);
220+
let int = ScalarInt::try_from_uint(int, Size::from_bits(1)).unwrap();
221+
return CValue::const_val(fx, layout, int);
222+
}
218223
ConstValue::Indirect { alloc_id, offset } => CValue::by_ref(
219224
Pointer::new(pointer_for_allocation(fx, alloc_id))
220225
.offset_i64(fx, i64::try_from(offset.bytes()).unwrap()),

0 commit comments

Comments
 (0)