Skip to content

Commit 9673005

Browse files
committed
Merge pull request #4703 from sanxiyn/remove-tps
Remove `tps` from `trans_enum_def` and `trans_struct_def`
2 parents ea02a9a + 0d1058a commit 9673005

File tree

1 file changed

+22
-25
lines changed

1 file changed

+22
-25
lines changed

src/librustc/middle/trans/base.rs

Lines changed: 22 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1986,7 +1986,7 @@ pub fn trans_struct_dtor(ccx: @crate_ctxt,
19861986
}
19871987

19881988
pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def,
1989-
id: ast::node_id, tps: ~[ast::ty_param], degen: bool,
1989+
id: ast::node_id, degen: bool,
19901990
path: @ast_map::path, vi: @~[ty::VariantInfo],
19911991
i: &mut uint) {
19921992
for vec::each(enum_definition.variants) |variant| {
@@ -2003,14 +2003,13 @@ pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def,
20032003
// Nothing to do.
20042004
}
20052005
ast::struct_variant_kind(struct_def) => {
2006-
trans_struct_def(ccx, struct_def, /*bad*/copy tps, path,
2006+
trans_struct_def(ccx, struct_def, path,
20072007
variant.node.id);
20082008
}
20092009
ast::enum_variant_kind(ref enum_definition) => {
20102010
trans_enum_def(ccx,
20112011
*enum_definition,
20122012
id,
2013-
/*bad*/copy tps,
20142013
degen,
20152014
path,
20162015
vi,
@@ -2062,11 +2061,11 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
20622061
trans_mod(ccx, m);
20632062
}
20642063
ast::item_enum(ref enum_definition, ref tps) => {
2065-
if tps.len() == 0u {
2064+
if tps.is_empty() {
20662065
let degen = (*enum_definition).variants.len() == 1u;
20672066
let vi = ty::enum_variants(ccx.tcx, local_def(item.id));
20682067
let mut i = 0;
2069-
trans_enum_def(ccx, (*enum_definition), item.id, /*bad*/copy *tps,
2068+
trans_enum_def(ccx, (*enum_definition), item.id,
20702069
degen, path, vi, &mut i);
20712070
}
20722071
}
@@ -2080,35 +2079,33 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
20802079
foreign::trans_foreign_mod(ccx, foreign_mod, abi);
20812080
}
20822081
ast::item_struct(struct_def, tps) => {
2083-
trans_struct_def(ccx, struct_def, tps, path, item.id);
2082+
if tps.is_empty() {
2083+
trans_struct_def(ccx, struct_def, path, item.id);
2084+
}
20842085
}
20852086
_ => {/* fall through */ }
20862087
}
20872088
}
20882089

20892090
pub fn trans_struct_def(ccx: @crate_ctxt, struct_def: @ast::struct_def,
2090-
tps: ~[ast::ty_param], path: @ast_map::path,
2091+
path: @ast_map::path,
20912092
id: ast::node_id) {
2092-
// If there are type parameters, the destructor and constructor will be
2093-
// monomorphized, so we don't translate them here.
2094-
if tps.len() == 0u {
2095-
// Translate the destructor.
2096-
do option::iter(&struct_def.dtor) |dtor| {
2097-
trans_struct_dtor(ccx, /*bad*/copy *path, dtor.node.body,
2098-
dtor.node.id, None, None, local_def(id));
2099-
};
2093+
// Translate the destructor.
2094+
do option::iter(&struct_def.dtor) |dtor| {
2095+
trans_struct_dtor(ccx, /*bad*/copy *path, dtor.node.body,
2096+
dtor.node.id, None, None, local_def(id));
2097+
};
21002098

2101-
// If this is a tuple-like struct, translate the constructor.
2102-
match struct_def.ctor_id {
2103-
// We only need to translate a constructor if there are fields;
2104-
// otherwise this is a unit-like struct.
2105-
Some(ctor_id) if struct_def.fields.len() > 0 => {
2106-
let llfndecl = get_item_val(ccx, ctor_id);
2107-
trans_tuple_struct(ccx, /*bad*/copy struct_def.fields,
2108-
ctor_id, None, llfndecl);
2109-
}
2110-
Some(_) | None => {}
2099+
// If this is a tuple-like struct, translate the constructor.
2100+
match struct_def.ctor_id {
2101+
// We only need to translate a constructor if there are fields;
2102+
// otherwise this is a unit-like struct.
2103+
Some(ctor_id) if struct_def.fields.len() > 0 => {
2104+
let llfndecl = get_item_val(ccx, ctor_id);
2105+
trans_tuple_struct(ccx, /*bad*/copy struct_def.fields,
2106+
ctor_id, None, llfndecl);
21112107
}
2108+
Some(_) | None => {}
21122109
}
21132110
}
21142111

0 commit comments

Comments
 (0)