mirror of
https://github.com/rust-lang/rust.git
synced 2025-02-18 09:53:26 +00:00
Translate MIR Repeat (arrays)
This commit is contained in:
parent
14db074659
commit
cba6561de2
@ -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) => {
|
||||
|
21
src/test/run-pass/mir_trans_array.rs
Normal file
21
src/test/run-pass/mir_trans_array.rs
Normal 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);
|
||||
}
|
Loading…
Reference in New Issue
Block a user