File tree Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Expand file tree Collapse file tree 2 files changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -474,7 +474,15 @@ fn trans_stmt<'a, 'tcx: 'a>(
474
474
to. write_cvalue ( fx, operand) ;
475
475
}
476
476
}
477
- Rvalue :: Len ( lval) => unimpl ! ( "rval len {:?}" , lval) ,
477
+ Rvalue :: Len ( place) => {
478
+ let place = trans_place ( fx, place) ;
479
+ let size = match place {
480
+ CPlace :: Addr ( _, size, _) => size. unwrap ( ) ,
481
+ CPlace :: Var ( _, _) => unreachable ! ( ) ,
482
+ } ;
483
+ let usize_layout = fx. layout_of ( fx. tcx . types . usize ) ;
484
+ lval. write_cvalue ( fx, CValue :: ByVal ( size, usize_layout) ) ;
485
+ }
478
486
Rvalue :: NullaryOp ( NullOp :: Box , ty) => unimplemented ! ( "rval box {:?}" , ty) ,
479
487
Rvalue :: NullaryOp ( NullOp :: SizeOf , ty) => {
480
488
assert ! (
Original file line number Diff line number Diff line change @@ -433,23 +433,20 @@ impl<'a, 'tcx: 'a> CPlace<'tcx> {
433
433
fx : & mut FunctionCx < ' a , ' tcx , impl Backend > ,
434
434
index : Value ,
435
435
) -> CPlace < ' tcx > {
436
- let addr = self . expect_addr ( ) ;
437
- let layout = self . layout ( ) ;
438
- if layout. is_unsized ( ) {
439
- unimpl ! ( "unsized place_field" ) ;
440
- }
441
-
442
- match layout. ty . sty {
436
+ match self . layout ( ) . ty . sty {
443
437
ty:: Array ( elem_ty, _) => {
444
438
let elem_layout = fx. layout_of ( elem_ty) ;
439
+
445
440
let offset = fx
446
441
. bcx
447
442
. ins ( )
448
443
. imul_imm ( index, elem_layout. size . bytes ( ) as i64 ) ;
444
+
445
+ let addr = self . expect_addr ( ) ;
449
446
CPlace :: Addr ( fx. bcx . ins ( ) . iadd ( addr, offset) , None , elem_layout)
450
447
}
451
- ty:: Slice ( _elem_ty) => unimplemented ! ( "place_index(TySlice)" ) ,
452
- _ => bug ! ( "place_index({:?})" , layout. ty) ,
448
+ ty:: Slice ( _elem_ty) => unimpl ! ( "place_index(TySlice)" ) ,
449
+ _ => bug ! ( "place_index({:?})" , self . layout( ) . ty) ,
453
450
}
454
451
}
455
452
You can’t perform that action at this time.
0 commit comments