@@ -1267,14 +1267,14 @@ pub fn compile_submatch(bcx: block,
1267
1267
}
1268
1268
1269
1269
bcx = root_pats_as_necessary(bcx, m, col, val);
1270
-
1271
1270
let rec_fields = collect_record_or_struct_fields(bcx, m, col);
1272
1271
if rec_fields.len() > 0 {
1273
1272
let pat_ty = node_id_type(bcx, pat_id);
1274
- do expr::with_field_tys(tcx, pat_ty, None) |_has_dtor, field_tys| {
1273
+ let pat_repr = adt::represent_type(bcx.ccx(), pat_ty);
1274
+ do expr::with_field_tys(tcx, pat_ty, None) |discr, field_tys| {
1275
1275
let rec_vals = rec_fields.map(|field_name| {
1276
1276
let ix = ty::field_idx_strict(tcx, *field_name, field_tys);
1277
- GEPi (bcx, val, struct_field(ix) )
1277
+ adt::trans_GEP (bcx, &pat_repr, val, discr, ix )
1278
1278
});
1279
1279
compile_submatch(
1280
1280
bcx,
@@ -1287,11 +1287,14 @@ pub fn compile_submatch(bcx: block,
1287
1287
1288
1288
if any_tup_pat(m, col) {
1289
1289
let tup_ty = node_id_type(bcx, pat_id);
1290
+ let tup_repr = adt::represent_type(bcx.ccx(), tup_ty);
1290
1291
let n_tup_elts = match /*bad*/copy ty::get(tup_ty).sty {
1291
1292
ty::ty_tup(elts) => elts.len(),
1292
1293
_ => ccx.sess.bug(~" non-tuple type in tuple pattern")
1293
1294
};
1294
- let tup_vals = vec::from_fn(n_tup_elts, |i| GEPi(bcx, val, [0u, i]));
1295
+ let tup_vals = do vec::from_fn(n_tup_elts) |i| {
1296
+ adt::trans_GEP(bcx, &tup_repr, val, 0, i)
1297
+ };
1295
1298
compile_submatch(bcx, enter_tup(bcx, dm, m, col, val, n_tup_elts),
1296
1299
vec::append(tup_vals, vals_left), chk);
1297
1300
return;
@@ -1310,8 +1313,10 @@ pub fn compile_submatch(bcx: block,
1310
1313
}
1311
1314
}
1312
1315
1313
- let llstructvals = vec::from_fn(
1314
- struct_element_count, |i| GEPi(bcx, val, struct_field(i)));
1316
+ let struct_repr = adt::represent_type(bcx.ccx(), struct_ty);
1317
+ let llstructvals = do vec::from_fn(struct_element_count) |i| {
1318
+ adt::trans_GEP(bcx, &struct_repr, val, 0, i)
1319
+ };
1315
1320
compile_submatch(bcx,
1316
1321
enter_tuple_struct(bcx, dm, m, col, val,
1317
1322
struct_element_count),
@@ -1745,9 +1750,11 @@ pub fn bind_irrefutable_pat(bcx: block,
1745
1750
// This is a unit-like struct. Nothing to do here.
1746
1751
}
1747
1752
Some ( elems) => {
1748
- // This is the tuple variant case.
1753
+ // This is the tuple struct case.
1754
+ let repr = adt:: represent_node ( bcx, pat. id ) ;
1749
1755
for vec:: eachi( elems) |i, elem| {
1750
- let fldptr = GEPi ( bcx, val, struct_field ( i) ) ;
1756
+ let fldptr = adt:: trans_GEP ( bcx, & repr,
1757
+ val, 0 , i) ;
1751
1758
bcx = bind_irrefutable_pat ( bcx,
1752
1759
* elem,
1753
1760
fldptr,
@@ -1765,10 +1772,12 @@ pub fn bind_irrefutable_pat(bcx: block,
1765
1772
ast:: pat_rec( fields, _) | ast:: pat_struct( _, fields, _) => {
1766
1773
let tcx = bcx. tcx ( ) ;
1767
1774
let pat_ty = node_id_type ( bcx, pat. id ) ;
1768
- do expr:: with_field_tys ( tcx, pat_ty, None ) |_hd, field_tys| {
1775
+ let pat_repr = adt:: represent_type ( bcx. ccx ( ) , pat_ty) ;
1776
+ do expr:: with_field_tys ( tcx, pat_ty, None ) |discr, field_tys| {
1769
1777
for vec:: each( fields) |f| {
1770
1778
let ix = ty:: field_idx_strict ( tcx, f. ident , field_tys) ;
1771
- let fldptr = GEPi ( bcx, val, struct_field ( ix) ) ;
1779
+ let fldptr = adt:: trans_GEP ( bcx, & pat_repr, val,
1780
+ discr, ix) ;
1772
1781
bcx = bind_irrefutable_pat ( bcx,
1773
1782
f. pat ,
1774
1783
fldptr,
@@ -1778,8 +1787,9 @@ pub fn bind_irrefutable_pat(bcx: block,
1778
1787
}
1779
1788
}
1780
1789
ast:: pat_tup( elems) => {
1790
+ let repr = adt:: represent_node ( bcx, pat. id ) ;
1781
1791
for vec:: eachi( elems) |i, elem| {
1782
- let fldptr = GEPi ( bcx, val, [ 0 u , i] ) ;
1792
+ let fldptr = adt :: trans_GEP ( bcx, & repr , val, 0 , i) ;
1783
1793
bcx = bind_irrefutable_pat ( bcx,
1784
1794
* elem,
1785
1795
fldptr,
0 commit comments