We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 59daf76 commit 075affaCopy full SHA for 075affa
src/librustc/middle/trans/consts.rs
@@ -240,16 +240,12 @@ fn const_expr_unchecked(cx: @CrateContext, e: @ast::expr) -> ValueRef {
240
}
241
ast::expr_field(base, field, _) => {
242
let bt = ty::expr_ty(cx.tcx, base);
243
+ let brepr = adt::represent_type(cx, bt);
244
let bv = const_expr(cx, base);
245
let (bt, bv) = const_autoderef(cx, bt, bv);
- do expr::with_field_tys(cx.tcx, bt, None) |_, field_tys| {
246
+ do expr::with_field_tys(cx.tcx, bt, None) |discr, field_tys| {
247
let ix = ty::field_idx_strict(cx.tcx, field, field_tys);
-
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])
+ adt::const_get_element(cx, &brepr, bv, discr, ix)
253
254
255
0 commit comments