Translate MIR Repeat (arrays)

This commit is contained in:
Simonas Kazlauskas 2015-11-05 16:50:36 +02:00
parent 14db074659
commit cba6561de2
2 changed files with 29 additions and 2 deletions

View File

@ -49,8 +49,14 @@ impl<'bcx, 'tcx> MirContext<'bcx, 'tcx> {
unimplemented!()
}
mir::Rvalue::Repeat(..) => {
unimplemented!()
mir::Rvalue::Repeat(ref elem, ref count) => {
let elem = self.trans_operand(bcx, elem);
let size = self.trans_operand(bcx, count);
let base = expr::get_dataptr(bcx, lldest);
tvec::iter_vec_raw(bcx, base, elem.ty, size.llval, |b, vref, _| {
build::Store(b, elem.llval, vref);
b
})
}
mir::Rvalue::Aggregate(_, ref operands) => {

View File

@ -0,0 +1,21 @@
// Copyright 2015 The Rust Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#![feature(rustc_attrs)]
#[rustc_mir]
fn into_inner() -> [u64; 1024] {
let mut x = 10 + 20;
[x; 1024]
}
fn main(){
let x: &[u64] = &[30; 1024];
assert_eq!(&into_inner()[..], x);
}