@@ -678,11 +678,10 @@ pub fn trans_place<'tcx>(
678
678
// slice[from:-to] in Python terms.
679
679
680
680
match cplace. layout ( ) . ty . kind {
681
- ty:: Array ( elem_ty, len) => {
681
+ ty:: Array ( elem_ty, _len) => {
682
+ assert ! ( !from_end, "array subslices are never `from_end`" ) ;
682
683
let elem_layout = fx. layout_of ( elem_ty) ;
683
684
let ptr = cplace. to_ptr ( fx) ;
684
- let len = crate :: constant:: force_eval_const ( fx, len)
685
- . eval_usize ( fx. tcx , ParamEnv :: reveal_all ( ) ) ;
686
685
cplace = CPlace :: for_ptr (
687
686
ptr. offset_i64 ( fx, elem_layout. size . bytes ( ) as i64 * from as i64 ) ,
688
687
fx. layout_of ( fx. tcx . mk_array ( elem_ty, to as u64 - from as u64 ) ) ,
@@ -691,11 +690,10 @@ pub fn trans_place<'tcx>(
691
690
ty:: Slice ( elem_ty) => {
692
691
assert ! ( from_end, "slice subslices should be `from_end`" ) ;
693
692
let elem_layout = fx. layout_of ( elem_ty) ;
694
- let ( ptr, len) = cplace. to_ptr_maybe_unsized ( fx) ;
695
- let len = len. unwrap ( ) ;
693
+ let ( ptr, _len) = cplace. to_ptr_maybe_unsized ( fx) ;
696
694
cplace = CPlace :: for_ptr_with_extra (
697
695
ptr. offset_i64 ( fx, elem_layout. size . bytes ( ) as i64 * from as i64 ) ,
698
- fx. bcx . ins ( ) . iadd_imm ( len , - ( from as i64 + to as i64 ) ) ,
696
+ fx. bcx . ins ( ) . iconst ( pointer_ty ( fx . tcx ) , ( to as u64 - from as u64 ) as i64 ) ,
699
697
cplace. layout ( ) ,
700
698
) ;
701
699
}
0 commit comments