Skip to content

Commit f5080aa

Browse files
committed
---
yaml --- r: 45020 b: refs/heads/master c: c7325c4 h: refs/heads/master v: v3
1 parent 2ca1aef commit f5080aa

File tree

2 files changed

+22
-12
lines changed

2 files changed

+22
-12
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 3a4714d92e49564c1cfc86fae5573510de7c2e31
2+
refs/heads/master: c7325c417257646afdd93fd3cc10ef891d167643
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: a6d9689399d091c3265f00434a69c551a61c28dc
55
refs/heads/try: ef355f6332f83371e4acf04fc4eb940ab41d78d3

trunk/src/librustc/middle/trans/_match.rs

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1267,14 +1267,14 @@ pub fn compile_submatch(bcx: block,
12671267
}
12681268
12691269
bcx = root_pats_as_necessary(bcx, m, col, val);
1270-
12711270
let rec_fields = collect_record_or_struct_fields(bcx, m, col);
12721271
if rec_fields.len() > 0 {
12731272
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| {
12751275
let rec_vals = rec_fields.map(|field_name| {
12761276
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)
12781278
});
12791279
compile_submatch(
12801280
bcx,
@@ -1287,11 +1287,14 @@ pub fn compile_submatch(bcx: block,
12871287
12881288
if any_tup_pat(m, col) {
12891289
let tup_ty = node_id_type(bcx, pat_id);
1290+
let tup_repr = adt::represent_type(bcx.ccx(), tup_ty);
12901291
let n_tup_elts = match /*bad*/copy ty::get(tup_ty).sty {
12911292
ty::ty_tup(elts) => elts.len(),
12921293
_ => ccx.sess.bug(~"non-tuple type in tuple pattern")
12931294
};
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+
};
12951298
compile_submatch(bcx, enter_tup(bcx, dm, m, col, val, n_tup_elts),
12961299
vec::append(tup_vals, vals_left), chk);
12971300
return;
@@ -1310,8 +1313,10 @@ pub fn compile_submatch(bcx: block,
13101313
}
13111314
}
13121315
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+
};
13151320
compile_submatch(bcx,
13161321
enter_tuple_struct(bcx, dm, m, col, val,
13171322
struct_element_count),
@@ -1745,9 +1750,11 @@ pub fn bind_irrefutable_pat(bcx: block,
17451750
// This is a unit-like struct. Nothing to do here.
17461751
}
17471752
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);
17491755
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);
17511758
bcx = bind_irrefutable_pat(bcx,
17521759
*elem,
17531760
fldptr,
@@ -1765,10 +1772,12 @@ pub fn bind_irrefutable_pat(bcx: block,
17651772
ast::pat_rec(fields, _) | ast::pat_struct(_, fields, _) => {
17661773
let tcx = bcx.tcx();
17671774
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| {
17691777
for vec::each(fields) |f| {
17701778
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);
17721781
bcx = bind_irrefutable_pat(bcx,
17731782
f.pat,
17741783
fldptr,
@@ -1778,8 +1787,9 @@ pub fn bind_irrefutable_pat(bcx: block,
17781787
}
17791788
}
17801789
ast::pat_tup(elems) => {
1790+
let repr = adt::represent_node(bcx, pat.id);
17811791
for vec::eachi(elems) |i, elem| {
1782-
let fldptr = GEPi(bcx, val, [0u, i]);
1792+
let fldptr = adt::trans_GEP(bcx, &repr, val, 0, i);
17831793
bcx = bind_irrefutable_pat(bcx,
17841794
*elem,
17851795
fldptr,

0 commit comments

Comments
 (0)