Skip to content

Commit 64963aa

Browse files
committed
---
yaml --- r: 106623 b: refs/heads/try c: d908302 h: refs/heads/master i: 106621: fa3aba3 106619: f02e890 106615: b0f0eb0 106607: 40d88c9 106591: 4cd5feb 106559: acd2a0e 106495: 546b03f v: v3
1 parent 99a9f02 commit 64963aa

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: b8ef9fd9c9f642ce7b8aed82782a1ed745d08d64
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: b8601a3d8b91ad3b653d143307611f2f5c75617e
5-
refs/heads/try: 67c5d793add67878e6e472258748ac13e0f90366
5+
refs/heads/try: d90830221e76ca41ac336a32f308f58e45ca4ae8
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

branches/try/src/librustc/middle/trans/adt.rs

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -749,14 +749,15 @@ pub fn trans_const(ccx: &CrateContext, r: &Repr, discr: Disr,
749749
let contents = build_const_struct(ccx, st, vals);
750750
C_struct(contents, st.packed)
751751
}
752-
NullablePointer{ nonnull: ref nonnull, nndiscr, ptrfield, .. } => {
752+
NullablePointer{ nonnull: ref nonnull, nndiscr, .. } => {
753753
if discr == nndiscr {
754754
C_struct(build_const_struct(ccx, nonnull, vals), false)
755755
} else {
756-
let vals = nonnull.fields.iter().enumerate().map(|(i, &ty)| {
757-
let llty = type_of::sizing_type_of(ccx, ty);
758-
if i == ptrfield { C_null(llty) } else { C_undef(llty) }
759-
}).collect::<~[ValueRef]>();
756+
let vals = nonnull.fields.map(|&ty| {
757+
// Always use null even if it's not the `ptrfield`th
758+
// field; see #8506.
759+
C_null(type_of::sizing_type_of(ccx, ty))
760+
});
760761
C_struct(build_const_struct(ccx, nonnull, vals), false)
761762
}
762763
}
@@ -791,14 +792,8 @@ fn build_const_struct(ccx: &CrateContext, st: &Struct, vals: &[ValueRef])
791792
cfields.push(padding(target_offset - offset));
792793
offset = target_offset;
793794
}
794-
let val = if is_undef(vals[i]) {
795-
let wrapped = C_struct([vals[i]], false);
796-
assert!(!is_undef(wrapped));
797-
wrapped
798-
} else {
799-
vals[i]
800-
};
801-
cfields.push(val);
795+
assert!(!is_undef(vals[i]));
796+
cfields.push(vals[i]);
802797
offset += machine::llsize_of_alloc(ccx, llty) as u64
803798
}
804799

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Copyright 2013-2014 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
#[allow(dead_code)];
12+
13+
enum Either {
14+
One,
15+
Other(~str,~str)
16+
}
17+
18+
static one : Either = One;
19+
20+
pub fn main () { }

0 commit comments

Comments
 (0)