Skip to content

Commit 0a117ea

Browse files
committed
---
yaml --- r: 46809 b: refs/heads/auto c: 075affa h: refs/heads/master i: 46807: 153bb3e v: v3
1 parent 3169277 commit 0a117ea

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,4 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1414
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1515
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1616
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
17-
refs/heads/auto: 59daf76a8db88ec2ea4640f0fbf598402d1a10cb
17+
refs/heads/auto: 075affa50d04c585a53d0c8e7b66bae372a72648

branches/auto/src/librustc/middle/trans/consts.rs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -240,16 +240,12 @@ fn const_expr_unchecked(cx: @CrateContext, e: @ast::expr) -> ValueRef {
240240
}
241241
ast::expr_field(base, field, _) => {
242242
let bt = ty::expr_ty(cx.tcx, base);
243+
let brepr = adt::represent_type(cx, bt);
243244
let bv = const_expr(cx, base);
244245
let (bt, bv) = const_autoderef(cx, bt, bv);
245-
do expr::with_field_tys(cx.tcx, bt, None) |_, field_tys| {
246+
do expr::with_field_tys(cx.tcx, bt, None) |discr, field_tys| {
246247
let ix = ty::field_idx_strict(cx.tcx, field, field_tys);
247-
248-
// Note: ideally, we'd use `struct_field()` here instead
249-
// of hardcoding [0, ix], but we can't because it yields
250-
// the wrong type and also inserts an extra 0 that is
251-
// not needed in the constant variety:
252-
const_get_elt(cx, bv, [0, ix as c_uint])
248+
adt::const_get_element(cx, &brepr, bv, discr, ix)
253249
}
254250
}
255251

0 commit comments

Comments
 (0)