@@ -884,13 +884,15 @@ fn trans_lvalue_unadjusted(bcx: block, expr: @ast::expr) -> DatumBlock {
884
884
let _icx = bcx. insn_ctxt ( "trans_rec_field" ) ;
885
885
886
886
let base_datum = unpack_datum ! ( bcx, trans_to_datum( bcx, base) ) ;
887
- do with_field_tys ( bcx. tcx ( ) , base_datum. ty , None ) |_disr, field_tys| {
887
+ let repr = adt:: represent_type ( bcx. ccx ( ) , base_datum. ty ) ;
888
+ do with_field_tys ( bcx. tcx ( ) , base_datum. ty , None ) |discr, field_tys| {
888
889
let ix = ty:: field_idx_strict ( bcx. tcx ( ) , field, field_tys) ;
889
890
DatumBlock {
890
- datum : base_datum. GEPi ( bcx,
891
- [ 0 u, 0 u, ix] ,
892
- field_tys[ ix] . mt . ty ,
893
- ZeroMem ) ,
891
+ datum : do base_datum. get_element ( bcx,
892
+ field_tys[ ix] . mt . ty ,
893
+ ZeroMem ) |srcval| {
894
+ adt:: trans_GEP ( bcx, & repr, srcval, discr, ix)
895
+ } ,
894
896
bcx : bcx
895
897
}
896
898
}
@@ -1227,11 +1229,13 @@ fn trans_adt(bcx: block, repr: &adt::Repr, discr: int,
1227
1229
temp_cleanups. push ( dest) ;
1228
1230
}
1229
1231
for optbase. each |base| {
1232
+ // XXX is it sound to use the destination's repr on the base?
1233
+ // XXX would it ever be reasonable to be here with discr != 0?
1230
1234
let base_datum = unpack_datum ! ( bcx, trans_to_datum( bcx, base. expr) ) ;
1231
1235
for base. fields. each |& ( i, t) | {
1232
- let datum =
1233
- // XXX convert this to adt
1234
- base_datum . GEPi ( bcx , struct_field ( i ) , t , ZeroMem ) ;
1236
+ let datum = do base_datum . get_element ( bcx , t , ZeroMem ) |srcval| {
1237
+ adt :: trans_GEP ( bcx , repr , srcval , discr , i )
1238
+ } ;
1235
1239
let dest = adt:: trans_GEP ( bcx, repr, addr, discr, i) ;
1236
1240
bcx = datum. store_to ( bcx, base. expr . id , INIT , dest) ;
1237
1241
}
0 commit comments