Skip to content

Commit dd48b5e

Browse files
committed
adjust constValue::Slice to work for arbitrary slice types
1 parent 247d38d commit dd48b5e

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/constant.rs

+4-8
Original file line numberDiff line numberDiff line change
@@ -184,15 +184,11 @@ pub(crate) fn codegen_const_value<'tcx>(
184184
.offset_i64(fx, i64::try_from(offset.bytes()).unwrap()),
185185
layout,
186186
),
187-
ConstValue::Slice { data, start, end } => {
187+
ConstValue::Slice { data, meta } => {
188188
let alloc_id = fx.tcx.reserve_and_set_memory_alloc(data);
189-
let ptr = pointer_for_allocation(fx, alloc_id)
190-
.offset_i64(fx, i64::try_from(start).unwrap())
191-
.get_addr(fx);
192-
let len = fx
193-
.bcx
194-
.ins()
195-
.iconst(fx.pointer_type, i64::try_from(end.checked_sub(start).unwrap()).unwrap());
189+
let ptr = pointer_for_allocation(fx, alloc_id).get_addr(fx);
190+
// FIXME: the `try_from` here can actually fail, e.g. for very long ZST slices.
191+
let len = fx.bcx.ins().iconst(fx.pointer_type, i64::try_from(meta).unwrap());
196192
CValue::by_val_pair(ptr, len, layout)
197193
}
198194
}

0 commit comments

Comments
 (0)