@@ -108,12 +108,13 @@ pub fn const_lit(cx: &CrateContext, e: &hir::Expr, lit: &ast::Lit)
108
108
}
109
109
}
110
110
111
- pub fn trans_constval < ' a , ' tcx > ( ccx : & CrateContext < ' a , ' tcx > ,
111
+ pub fn trans_constval < ' blk , ' tcx > ( bcx : common :: Block < ' blk , ' tcx > ,
112
112
cv : & ConstVal ,
113
113
ty : Ty < ' tcx > ,
114
114
param_substs : & ' tcx Substs < ' tcx > )
115
115
-> ValueRef
116
116
{
117
+ let ccx = bcx. ccx ( ) ;
117
118
let llty = type_of:: type_of ( ccx, ty) ;
118
119
match * cv {
119
120
ConstVal :: Float ( v) => C_floating_f64 ( v, llty) ,
@@ -123,19 +124,17 @@ pub fn trans_constval<'a, 'tcx>(ccx: &CrateContext<'a, 'tcx>,
123
124
ConstVal :: Str ( ref v) => C_str_slice ( ccx, v. clone ( ) ) ,
124
125
ConstVal :: ByteStr ( ref v) => addr_of ( ccx, C_bytes ( ccx, v) , 1 , "byte_str" ) ,
125
126
ConstVal :: Struct ( id) | ConstVal :: Tuple ( id) => {
126
- let expr = ccx . tcx ( ) . map . expect_expr ( id) ;
127
+ let expr = bcx . tcx ( ) . map . expect_expr ( id) ;
127
128
match const_expr ( ccx, expr, param_substs, None , TrueConst :: Yes ) {
128
129
Ok ( ( val, _) ) => val,
129
130
Err ( e) => panic ! ( "const eval failure: {}" , e. description( ) ) ,
130
131
}
131
132
} ,
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
137
136
} ,
138
- ConstVal :: Repeat ( .. ) => {
137
+ ConstVal :: Function ( _ ) => {
139
138
unimplemented ! ( )
140
139
} ,
141
140
}
0 commit comments