@@ -205,24 +205,28 @@ pub fn trans_GEP(bcx: block, r: &Repr, val: ValueRef, discr: int, ix: uint)
205
205
NoDtor => val,
206
206
DtorPresent | DtorAbsent => GEPi ( bcx, val, [ 0 , 0 ] )
207
207
} ;
208
- struct_GEP ( bcx, st, val, ix)
208
+ struct_GEP ( bcx, st, val, ix, false )
209
209
}
210
210
General ( ref cases) => {
211
211
struct_GEP ( bcx, & cases[ discr as uint ] ,
212
- GEPi ( bcx, val, [ 0 , 1 ] ) , ix)
212
+ GEPi ( bcx, val, [ 0 , 1 ] ) , ix, true )
213
213
}
214
214
}
215
215
}
216
216
217
- fn struct_GEP ( bcx : block , st : & Struct , val : ValueRef , ix : uint )
218
- -> ValueRef {
217
+ fn struct_GEP ( bcx : block , st : & Struct , val : ValueRef , ix : uint ,
218
+ needs_cast : bool ) -> ValueRef {
219
219
let ccx = bcx. ccx ( ) ;
220
220
221
- let real_llty = T_struct ( st. fields . map (
222
- |& ty| type_of:: type_of ( ccx, ty) ) ) ;
223
- let cast_val = PointerCast ( bcx, val, T_ptr ( real_llty) ) ;
221
+ let val = if needs_cast {
222
+ let real_llty = T_struct ( st. fields . map (
223
+ |& ty| type_of:: type_of ( ccx, ty) ) ) ;
224
+ PointerCast ( bcx, val, T_ptr ( real_llty) )
225
+ } else {
226
+ val
227
+ } ;
224
228
225
- GEPi ( bcx, cast_val , [ 0 , ix] )
229
+ GEPi ( bcx, val , [ 0 , ix] )
226
230
}
227
231
228
232
pub fn trans_const ( ccx : @CrateContext , r : & Repr , discr : int ,
0 commit comments