@@ -108,12 +108,13 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
108108 }
109109}
110110
111- pub fn trans_constval < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
111+ pub fn trans_constval < ' blk , ' tcx > ( bcx : common :: Block < ' blk , ' tcx > ,
112112 cv : & ConstVal ,
113113 ty : Ty < ' tcx > ,
114114 param_substs : & ' tcx Substs < ' tcx > )
115115 -> ValueRef
116116{
117+ let ccx = bcx. ccx ( ) ;
117118 let llty = type_of:: type_of ( ccx, ty) ;
118119 match * cv {
119120 ConstVal :: Float ( v) => C_floating_f64 ( v, llty) ,
@@ -123,19 +124,17 @@ pub fn trans_constval<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
123124 ConstVal :: Str ( ref v) => C_str_slice ( ccx, v. clone ( ) ) ,
124125 ConstVal :: ByteStr ( ref v) => addr_of ( ccx, C_bytes ( ccx, v) , 1 , "byte_str" ) ,
125126 ConstVal :: Struct ( id) | ConstVal :: Tuple ( id) => {
126- let expr = ccx . tcx ( ) . map . expect_expr ( id) ;
127+ let expr = bcx . tcx ( ) . map . expect_expr ( id) ;
127128 match const_expr ( ccx, expr, param_substs, None , TrueConst :: Yes ) {
128129 Ok ( ( val, _) ) => val,
129130 Err ( e) => panic ! ( "const eval failure: {}" , e. description( ) ) ,
130131 }
131132 } ,
132- ConstVal :: Function ( _) => {
133- unimplemented ! ( )
134- } ,
135- ConstVal :: Array ( ..) => {
136- unimplemented ! ( )
133+ ConstVal :: Array ( id, _) | ConstVal :: Repeat ( id, _) => {
134+ let expr = ccx. tcx ( ) . map . expect_expr ( id) ;
135+ expr:: trans ( bcx, expr) . datum . val
137136 } ,
138- ConstVal :: Repeat ( .. ) => {
137+ ConstVal :: Function ( _ ) => {
139138 unimplemented ! ( )
140139 } ,
141140 }
0 commit comments