1
Fork 0

Merge pull request #4703 from sanxiyn/remove-tps

Remove `tps` from `trans_enum_def` and `trans_struct_def`
This commit is contained in:
Brian Anderson 2013-01-31 16:59:47 -08:00
commit 9673005afe

View file

@ -1986,7 +1986,7 @@ pub fn trans_struct_dtor(ccx: @crate_ctxt,
}
pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def,
id: ast::node_id, tps: ~[ast::ty_param], degen: bool,
id: ast::node_id, degen: bool,
path: @ast_map::path, vi: @~[ty::VariantInfo],
i: &mut uint) {
for vec::each(enum_definition.variants) |variant| {
@ -2003,14 +2003,13 @@ pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def,
// Nothing to do.
}
ast::struct_variant_kind(struct_def) => {
trans_struct_def(ccx, struct_def, /*bad*/copy tps, path,
trans_struct_def(ccx, struct_def, path,
variant.node.id);
}
ast::enum_variant_kind(ref enum_definition) => {
trans_enum_def(ccx,
*enum_definition,
id,
/*bad*/copy tps,
degen,
path,
vi,
@ -2062,11 +2061,11 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
trans_mod(ccx, m);
}
ast::item_enum(ref enum_definition, ref tps) => {
if tps.len() == 0u {
if tps.is_empty() {
let degen = (*enum_definition).variants.len() == 1u;
let vi = ty::enum_variants(ccx.tcx, local_def(item.id));
let mut i = 0;
trans_enum_def(ccx, (*enum_definition), item.id, /*bad*/copy *tps,
trans_enum_def(ccx, (*enum_definition), item.id,
degen, path, vi, &mut i);
}
}
@ -2080,18 +2079,17 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
foreign::trans_foreign_mod(ccx, foreign_mod, abi);
}
ast::item_struct(struct_def, tps) => {
trans_struct_def(ccx, struct_def, tps, path, item.id);
if tps.is_empty() {
trans_struct_def(ccx, struct_def, path, item.id);
}
}
_ => {/* fall through */ }
}
}
pub fn trans_struct_def(ccx: @crate_ctxt, struct_def: @ast::struct_def,
tps: ~[ast::ty_param], path: @ast_map::path,
path: @ast_map::path,
id: ast::node_id) {
// If there are type parameters, the destructor and constructor will be
// monomorphized, so we don't translate them here.
if tps.len() == 0u {
// Translate the destructor.
do option::iter(&struct_def.dtor) |dtor| {
trans_struct_dtor(ccx, /*bad*/copy *path, dtor.node.body,
@ -2110,7 +2108,6 @@ pub fn trans_struct_def(ccx: @crate_ctxt, struct_def: @ast::struct_def,
Some(_) | None => {}
}
}
}
// Translate a module. Doing this amounts to translating the items in the
// module; there ends up being no artifact (aside from linkage names) of