]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_trans/trans/consts.rs
Auto merge of #30457 - Manishearth:rollup, r=Manishearth
[rust.git] / src / librustc_trans / trans / consts.rs
index 77664f19aac2ae0c0f1776a366e978616b92dba8..038e699a043ab4d755c17484959defab7227ed98 100644 (file)
@@ -108,12 +108,13 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
     }
 }
 
-pub fn trans_constval<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
+pub fn trans_constval<'blk, 'tcx>(bcx: common::Block<'blk, 'tcx>,
                                 cv: &ConstVal,
                                 ty: Ty<'tcx>,
                                 param_substs: &'tcx Substs<'tcx>)
                                 -> ValueRef
 {
+    let ccx = bcx.ccx();
     let llty = type_of::type_of(ccx, ty);
     match *cv {
         ConstVal::Float(v) => C_floating_f64(v, llty),
@@ -123,19 +124,17 @@ pub fn trans_constval<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
         ConstVal::Str(ref v) => C_str_slice(ccx, v.clone()),
         ConstVal::ByteStr(ref v) => addr_of(ccx, C_bytes(ccx, v), 1, "byte_str"),
         ConstVal::Struct(id) | ConstVal::Tuple(id) => {
-            let expr = ccx.tcx().map.expect_expr(id);
+            let expr = bcx.tcx().map.expect_expr(id);
             match const_expr(ccx, expr, param_substs, None, TrueConst::Yes) {
                 Ok((val, _)) => val,
                 Err(e) => panic!("const eval failure: {}", e.description()),
             }
         },
-        ConstVal::Function(_) => {
-            unimplemented!()
+        ConstVal::Array(id, _) | ConstVal::Repeat(id, _) => {
+            let expr = bcx.tcx().map.expect_expr(id);
+            expr::trans(bcx, expr).datum.val
         },
-        ConstVal::Array(..) => {
-            unimplemented!()
-        },
-        ConstVal::Repeat(..) => {
+        ConstVal::Function(_) => {
             unimplemented!()
         },
     }
@@ -1038,7 +1037,7 @@ pub fn trans_static(ccx: &CrateContext,
                     m: hir::Mutability,
                     expr: &hir::Expr,
                     id: ast::NodeId,
-                    attrs: &Vec<ast::Attribute>)
+                    attrs: &[ast::Attribute])
                     -> Result<ValueRef, ConstEvalErr> {
     unsafe {
         let _icx = push_ctxt("trans_static");