Skip to content

Commit a3c36e1

Browse files
committed
---
yaml --- r: 47769 b: refs/heads/incoming c: a2068f1 h: refs/heads/master i: 47767: 5b6e121 v: v3
1 parent d53ab11 commit a3c36e1

File tree

4 files changed

+18
-10
lines changed

4 files changed

+18
-10
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: 2a8fb58d79e685d5ca07b039badcf2ae3ef077ea
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 092b6114c114edbe6f9930291aca74f549b2b64a
9+
refs/heads/incoming: a2068f1b219d79aec867834e7790fbba399abc57
1010
refs/heads/dist-snap: 8b98e5a296d95c5e832db0756828e5bec31c6f50
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/src/librustc/middle/trans/type_of.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -328,11 +328,20 @@ pub fn type_of(cx: @crate_ctxt, t: ty::t) -> TypeRef {
328328
pub fn enum_body_types(cx: @crate_ctxt, did: ast::def_id, t: ty::t)
329329
-> ~[TypeRef] {
330330
let univar = ty::enum_is_univariant(cx.tcx, did);
331-
let size = machine::static_size_of_enum(cx, t);
332331
if !univar {
332+
let size = machine::static_size_of_enum(cx, t);
333333
~[T_enum_discrim(cx), T_array(T_i8(), size)]
334-
} else {
335-
~[T_array(T_i8(), size)]
334+
}
335+
else {
336+
// Use the actual fields, so we get the alignment right.
337+
match ty::get(t).sty {
338+
ty::ty_enum(_, ref substs) => {
339+
do ty::enum_variants(cx.tcx, did)[0].args.map |&field_ty| {
340+
sizing_type_of(cx, ty::subst(cx.tcx, substs, field_ty))
341+
}
342+
}
343+
_ => cx.sess.bug(~"enum is not an enum")
344+
}
336345
}
337346
}
338347

branches/incoming/src/librustc/middle/typeck/check/_match.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,6 @@ pub fn check_pat(pcx: pat_ctxt, pat: @ast::pat, expected: ty::t) {
362362
ast::pat_ident(*) if pat_is_const(tcx.def_map, pat) => {
363363
let const_did = ast_util::def_id_of_def(tcx.def_map.get(&pat.id));
364364
let const_tpt = ty::lookup_item_type(tcx, const_did);
365-
demand::suptype(fcx, pat.span, expected, const_tpt.ty);
366365
fcx.write_ty(pat.id, const_tpt.ty);
367366
}
368367
ast::pat_ident(bm, name, sub) if pat_is_binding(tcx.def_map, pat) => {

branches/incoming/src/test/compile-fail/issue-4968.rs renamed to branches/incoming/src/test/run-pass/const-enum-newtype-align.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11-
// Regression test for issue #4968
11+
enum E = u32;
12+
struct S { a: u8, b: E }
13+
const C: S = S { a: 0xA5, b: E(0xDEADBEEF) };
1214

13-
const A: (int,int) = (4,2);
14-
fn main() {
15-
match 42 { A => () } //~ ERROR mismatched types: expected `<VI0>` but found `(int,int)` (expected integral variable but found tuple)
15+
pub fn main() {
16+
assert C.b == 0xDEADBEEF;
1617
}
17-

0 commit comments

Comments
 (0)