Skip to content

Commit 3fe772f

Browse files
committed
---
yaml --- r: 46811 b: refs/heads/auto c: ca450e3 h: refs/heads/master i: 46809: 0a117ea 46807: 153bb3e v: v3
1 parent 74b84b0 commit 3fe772f

File tree

3 files changed

+14
-23
lines changed

3 files changed

+14
-23
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: 6bb6baba2cbcd885b53709bdd907e7053867a71e
17+
refs/heads/auto: ca450e345f57f277c1cb0406b8366280c8d41f48

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

Lines changed: 12 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ use middle::astencode;
3939
use middle::borrowck::RootInfo;
4040
use middle::resolve;
4141
use middle::trans::_match;
42+
use middle::trans::adt;
4243
use middle::trans::base;
4344
use middle::trans::build::*;
4445
use middle::trans::callee;
@@ -1861,7 +1862,6 @@ pub fn trans_enum_variant(ccx: @CrateContext,
18611862
variant: ast::variant,
18621863
args: &[ast::variant_arg],
18631864
disr: int,
1864-
is_degen: bool,
18651865
param_substs: Option<@param_substs>,
18661866
llfndecl: ValueRef) {
18671867
let _icx = ccx.insn_ctxt("trans_enum_variant");
@@ -1890,21 +1890,15 @@ pub fn trans_enum_variant(ccx: @CrateContext,
18901890
let arg_tys = ty::ty_fn_args(node_id_type(bcx, variant.node.id));
18911891
let bcx = copy_args_to_allocas(fcx, bcx, fn_args, raw_llargs, arg_tys);
18921892

1893-
// Cast the enum to a type we can GEP into.
1894-
let llblobptr = if is_degen {
1895-
fcx.llretptr
1896-
} else {
1897-
let llenumptr =
1898-
PointerCast(bcx, fcx.llretptr, T_opaque_enum_ptr(ccx));
1899-
let lldiscrimptr = GEPi(bcx, llenumptr, [0u, 0u]);
1900-
Store(bcx, C_int(ccx, disr), lldiscrimptr);
1901-
GEPi(bcx, llenumptr, [0u, 1u])
1902-
};
1903-
let t_id = local_def(enum_id);
1904-
let v_id = local_def(variant.node.id);
1893+
// XXX is there a better way to reconstruct the ty::t?
1894+
let enum_ty = ty::subst_tps(ccx.tcx, ty_param_substs, None,
1895+
ty::node_id_to_type(ccx.tcx, enum_id));
1896+
let repr = adt::represent_type(ccx, enum_ty);
1897+
1898+
adt::trans_set_discr(bcx, &repr, fcx.llretptr, disr);
19051899
for vec::eachi(args) |i, va| {
1906-
let lldestptr = GEP_enum(bcx, llblobptr, t_id, v_id,
1907-
/*bad*/copy ty_param_substs, i);
1900+
let lldestptr = adt::trans_GEP(bcx, &repr, fcx.llretptr, disr, i);
1901+
19081902
// If this argument to this function is a enum, it'll have come in to
19091903
// this function as an opaque blob due to the way that type_of()
19101904
// works. So we have to cast to the destination's view of the type.
@@ -2014,7 +2008,7 @@ pub fn trans_struct_dtor(ccx: @CrateContext,
20142008
}
20152009
20162010
pub fn trans_enum_def(ccx: @CrateContext, enum_definition: ast::enum_def,
2017-
id: ast::node_id, degen: bool,
2011+
id: ast::node_id,
20182012
path: @ast_map::path, vi: @~[ty::VariantInfo],
20192013
i: &mut uint) {
20202014
for vec::each(enum_definition.variants) |variant| {
@@ -2025,7 +2019,7 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: ast::enum_def,
20252019
ast::tuple_variant_kind(ref args) if args.len() > 0 => {
20262020
let llfn = get_item_val(ccx, variant.node.id);
20272021
trans_enum_variant(ccx, id, *variant, /*bad*/copy *args,
2028-
disr_val, degen, None, llfn);
2022+
disr_val, None, llfn);
20292023
}
20302024
ast::tuple_variant_kind(_) => {
20312025
// Nothing to do.
@@ -2038,7 +2032,6 @@ pub fn trans_enum_def(ccx: @CrateContext, enum_definition: ast::enum_def,
20382032
trans_enum_def(ccx,
20392033
*enum_definition,
20402034
id,
2041-
degen,
20422035
path,
20432036
vi,
20442037
&mut *i);
@@ -2089,11 +2082,10 @@ pub fn trans_item(ccx: @CrateContext, item: ast::item) {
20892082
}
20902083
ast::item_enum(ref enum_definition, ref generics) => {
20912084
if !generics.is_type_parameterized() {
2092-
let degen = (*enum_definition).variants.len() == 1u;
20932085
let vi = ty::enum_variants(ccx.tcx, local_def(item.id));
20942086
let mut i = 0;
20952087
trans_enum_def(ccx, (*enum_definition), item.id,
2096-
degen, path, vi, &mut i);
2088+
path, vi, &mut i);
20972089
}
20982090
}
20992091
ast::item_const(_, expr) => consts::trans_const(ccx, expr, item.id),

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,8 +196,7 @@ pub fn monomorphic_fn(ccx: @CrateContext,
196196
match (*v).node.kind {
197197
ast::tuple_variant_kind(ref args) => {
198198
trans_enum_variant(ccx, enum_item.id, *v, /*bad*/copy *args,
199-
this_tv.disr_val, tvs.len() == 1u,
200-
psubsts, d);
199+
this_tv.disr_val, psubsts, d);
201200
}
202201
ast::struct_variant_kind(_) =>
203202
ccx.tcx.sess.bug(~"can't monomorphize struct variants"),

0 commit comments

Comments
 (0)