From 1305d1ef238731c28495b9ee40cace982588cc46 Mon Sep 17 00:00:00 2001 From: bjorn3 Date: Wed, 8 Aug 2018 12:30:25 +0200 Subject: [PATCH] Implement Rvalue::Repeat --- examples/example.rs | 4 ++++ src/base.rs | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/examples/example.rs b/examples/example.rs index 74735c6a12d..ecc5db5c0db 100644 --- a/examples/example.rs +++ b/examples/example.rs @@ -146,3 +146,7 @@ unsafe fn call_uninit() -> u8 { fn use_array(arr: [u8; 3]) -> u8 { arr[1] } + +fn repeat_array() -> [u8; 3] { + [0; 3] +} diff --git a/src/base.rs b/src/base.rs index 723eb8cdc76..ad37f585677 100644 --- a/src/base.rs +++ b/src/base.rs @@ -412,7 +412,12 @@ fn trans_stmt<'a, 'tcx: 'a>( lval.write_cvalue(fx, discr); } Rvalue::Repeat(operand, times) => { - unimplemented!("rval repeat {:?} {:?}", operand, times) + let operand = trans_operand(fx, operand); + for i in 0..*times { + let index = fx.bcx.ins().iconst(types::I64, i as i64); + let to = lval.place_index(fx, index); + to.write_cvalue(fx, operand); + } } Rvalue::Len(lval) => return Err(format!("rval len {:?}", lval)), Rvalue::NullaryOp(NullOp::Box, ty) => unimplemented!("rval box {:?}", ty),