Skip to content

Commit a07b00a

Browse files
committed
---
yaml --- r: 42375 b: refs/heads/master c: de8dc02 h: refs/heads/master i: 42373: 3c61ed5 42371: 5222353 42367: 5530c1c v: v3
1 parent badd368 commit a07b00a

File tree

4 files changed

+41
-5
lines changed

4 files changed

+41
-5
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: 30aae3d9102c42aacde454620247e5b99c5acfd2
2+
refs/heads/master: de8dc026341671b1118d06dd2ada060067448988
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: 2f46b763da2c098913884f101b6d71d69af41b49
55
refs/heads/try: 3d5418789064fdb463e872a4e651af1c628a3650

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,12 @@ pub fn const_expr(cx: @crate_ctxt, e: @ast::expr) -> ValueRef {
459459
ast::expr_call(callee, args, _) => {
460460
match cx.tcx.def_map.find(&callee.id) {
461461
Some(ast::def_struct(def_id)) => {
462-
let ety = ty::expr_ty(cx.tcx, e);
463-
let llty = type_of::type_of(cx, ety);
464462
let llstructbody =
465463
C_struct(args.map(|a| const_expr(cx, *a)));
466464
if ty::ty_dtor(cx.tcx, def_id).is_present() {
467-
C_named_struct(llty, ~[ llstructbody, C_u8(0) ])
465+
C_struct(~[ llstructbody, C_u8(0) ])
468466
} else {
469-
C_named_struct(llty, ~[ llstructbody ])
467+
C_struct(~[ llstructbody ])
470468
}
471469
}
472470
Some(ast::def_variant(tid, vid)) => {
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 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+
enum E { V16(u16), V32(u32) }
12+
struct S(E, u16, u16);
13+
const C: S = S(V16(0xDEAD), 0x600D, 0xBAD);
14+
15+
fn main() {
16+
let S(_, n, _) = C;
17+
assert n != 0xBAD;
18+
assert n == 0x600D;
19+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// Copyright 2013 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+
enum E { V0, V16(u16) }
12+
struct S(E, u16, u16);
13+
const C: S = S(V0, 0x600D, 0xBAD);
14+
15+
fn main() {
16+
let S(_, n, _) = C;
17+
assert n != 0xBAD;
18+
assert n == 0x600D;
19+
}

0 commit comments

Comments
 (0)