pub(crate) fn check_constants(fx: &mut FunctionCx<'_, '_, impl Module>) {
for constant in &fx.mir.required_consts {
- let const_ = fx.monomorphize(&constant.literal);
+ let const_ = fx.monomorphize(constant.literal);
match const_.val {
ConstKind::Value(_) => {}
ConstKind::Unevaluated(def, ref substs, promoted) => {
let global_ptr = fx.bcx.ins().global_value(fx.pointer_type, local_data_id);
assert!(!layout.is_unsized(), "unsized statics aren't supported");
assert!(
- matches!(fx.bcx.func.global_values[local_data_id], GlobalValueData::Symbol { tls: false, ..}),
+ matches!(
+ fx.bcx.func.global_values[local_data_id],
+ GlobalValueData::Symbol { tls: false, .. }
+ ),
"tls static referenced without Rvalue::ThreadLocalRef"
);
CPlace::for_ptr(crate::pointer::Pointer::new(global_ptr), layout)
fx: &mut FunctionCx<'_, 'tcx, impl Module>,
constant: &Constant<'tcx>,
) -> CValue<'tcx> {
- let const_ = fx.monomorphize(&constant.literal);
+ let const_ = fx.monomorphize(constant.literal);
let const_val = match const_.val {
ConstKind::Value(const_val) => const_val,
ConstKind::Unevaluated(def, ref substs, promoted) if fx.tcx.is_static(def.did) => {
{
Ok(const_val) => const_val,
Err(_) => {
- if promoted.is_none() {
- fx.tcx
- .sess
- .span_err(constant.span, "erroneous constant encountered");
- }
+ fx.tcx
+ .sess
+ .span_err(constant.span, "erroneous constant encountered");
return crate::trap::trap_unreachable_ret_value(
fx,
fx.layout_of(const_.ty),
assert!(!layout.is_unsized(), "sized const value");
if layout.is_zst() {
- return CValue::by_ref(
- crate::Pointer::dangling(layout.align.pref),
- layout,
- );
+ return CValue::by_ref(crate::Pointer::dangling(layout.align.pref), layout);
}
match const_val {
}
match x {
- Scalar::Int(int) => {
- CValue::const_val(fx, layout, int)
- }
+ Scalar::Int(int) => CValue::const_val(fx, layout, int),
Scalar::Ptr(ptr) => {
let alloc_kind = fx.tcx.get_global_alloc(ptr.alloc_id);
let base_addr = match alloc_kind {
data_ctx.write_data_addr(offset.bytes() as u32, global_value, addend as i64);
}
- module.define_data(data_id, &data_ctx).unwrap();
+ // FIXME don't duplicate definitions in lazy jit mode
+ let _ = module.define_data(data_id, &data_ctx);
cx.done.insert(data_id);
}
match operand {
Operand::Copy(_) | Operand::Move(_) => None,
Operand::Constant(const_) => Some(
- fx.monomorphize(&const_.literal)
+ fx.monomorphize(const_.literal)
.eval(fx.tcx, ParamEnv::reveal_all()),
),
}