@@ -1986,7 +1986,7 @@ pub fn trans_struct_dtor(ccx: @crate_ctxt,
1986
1986
}
1987
1987
1988
1988
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 ,
1990
1990
path: @ast_map:: path, vi: @~[ ty:: VariantInfo ] ,
1991
1991
i: & mut uint) {
1992
1992
for vec:: each( enum_definition. variants) |variant| {
@@ -2003,14 +2003,13 @@ pub fn trans_enum_def(ccx: @crate_ctxt, enum_definition: ast::enum_def,
2003
2003
// Nothing to do.
2004
2004
}
2005
2005
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,
2007
2007
variant. node . id ) ;
2008
2008
}
2009
2009
ast:: enum_variant_kind( ref enum_definition) => {
2010
2010
trans_enum_def ( ccx,
2011
2011
* enum_definition,
2012
2012
id,
2013
- /*bad*/ copy tps,
2014
2013
degen,
2015
2014
path,
2016
2015
vi,
@@ -2062,11 +2061,11 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
2062
2061
trans_mod ( ccx, m) ;
2063
2062
}
2064
2063
ast:: item_enum( ref enum_definition, ref tps) => {
2065
- if tps. len ( ) == 0 u {
2064
+ if tps. is_empty ( ) {
2066
2065
let degen = ( * enum_definition) . variants . len ( ) == 1 u;
2067
2066
let vi = ty:: enum_variants ( ccx. tcx , local_def ( item. id ) ) ;
2068
2067
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 ,
2070
2069
degen, path, vi, & mut i) ;
2071
2070
}
2072
2071
}
@@ -2080,35 +2079,33 @@ pub fn trans_item(ccx: @crate_ctxt, item: ast::item) {
2080
2079
foreign:: trans_foreign_mod ( ccx, foreign_mod, abi) ;
2081
2080
}
2082
2081
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
+ }
2084
2085
}
2085
2086
_ => { /* fall through */ }
2086
2087
}
2087
2088
}
2088
2089
2089
2090
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 ,
2091
2092
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 ( ) == 0 u {
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
+ } ;
2100
2098
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) ;
2111
2107
}
2108
+ Some ( _) | None => { }
2112
2109
}
2113
2110
}
2114
2111
0 commit comments