Skip to content

Commit ee4bed1

Browse files
committed
Fix subslice length handling for slices
1 parent 31839d3 commit ee4bed1

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/base.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -690,10 +690,11 @@ pub fn trans_place<'tcx>(
690690
ty::Slice(elem_ty) => {
691691
assert!(from_end, "slice subslices should be `from_end`");
692692
let elem_layout = fx.layout_of(elem_ty);
693-
let (ptr, _len) = cplace.to_ptr_maybe_unsized(fx);
693+
let (ptr, len) = cplace.to_ptr_maybe_unsized(fx);
694+
let len = len.unwrap();
694695
cplace = CPlace::for_ptr_with_extra(
695696
ptr.offset_i64(fx, elem_layout.size.bytes() as i64 * from as i64),
696-
fx.bcx.ins().iconst(pointer_ty(fx.tcx), (to as u64 - from as u64) as i64),
697+
fx.bcx.ins().iadd_imm(len, -(from as i64 + to as i64)),
697698
cplace.layout(),
698699
);
699700
}

0 commit comments

Comments
 (0)