@@ -2153,29 +2153,29 @@ fn monomorphic_fn(ccx: @crate_ctxt, fn_id: ast::def_id, substs: [ty::t],
2153
2153
alt check map_node {
2154
2154
ast_map : : node_item ( i @@{ node : ast:: item_fn ( decl, _, body) , _} , _) {
2155
2155
set_inline_hint_if_appr ( i. attrs , lldecl) ;
2156
- trans_fn ( ccx, pt, decl, body, lldecl, no_self, [ ] ,
2157
- psubsts , fn_id . node , none) ;
2156
+ trans_fn ( ccx, pt, decl, body, lldecl, no_self, psubsts , fn_id . node ,
2157
+ none) ;
2158
2158
}
2159
2159
ast_map:: node_variant ( v, enum_item, _) {
2160
2160
let tvs = ty:: enum_variants ( ccx. tcx , local_def ( enum_item. id ) ) ;
2161
2161
let this_tv = option:: get ( vec:: find ( * tvs, { |tv|
2162
2162
tv. id . node == fn_id. node } ) ) ;
2163
2163
set_inline_hint ( lldecl) ;
2164
2164
trans_enum_variant ( ccx, enum_item. id , v, this_tv. disr_val ,
2165
- ( * tvs) . len ( ) == 1 u, [ ] , psubsts, lldecl) ;
2165
+ ( * tvs) . len ( ) == 1 u, psubsts, lldecl) ;
2166
2166
}
2167
2167
ast_map:: node_method ( mth, impl_def_id, _) {
2168
2168
set_inline_hint_if_appr ( mth. attrs , lldecl) ;
2169
2169
let selfty = ty:: node_id_to_type ( ccx. tcx , mth. self_id ) ;
2170
2170
let selfty = ty:: substitute_type_params ( ccx. tcx , substs, selfty) ;
2171
2171
trans_fn ( ccx, pt, mth. decl , mth. body , lldecl,
2172
- impl_self ( selfty) , [ ] , psubsts, fn_id. node , none) ;
2172
+ impl_self ( selfty) , psubsts, fn_id. node , none) ;
2173
2173
}
2174
2174
ast_map:: node_ctor ( i) {
2175
2175
alt check ccx. tcx . items . get ( i. id ) {
2176
2176
ast_map:: node_item ( @{ node: ast:: item_res ( decl, _, _, _, _) , _} , _) {
2177
2177
set_inline_hint ( lldecl) ;
2178
- trans_res_ctor ( ccx, pt, decl, fn_id. node , [ ] , psubsts, lldecl) ;
2178
+ trans_res_ctor ( ccx, pt, decl, fn_id. node , psubsts, lldecl) ;
2179
2179
}
2180
2180
ast_map:: node_item ( @{ node: ast:: item_class ( _, _, ctor) , _} , _) {
2181
2181
ccx. sess . unimpl ( "monomorphic class constructor" ) ;
@@ -2216,10 +2216,11 @@ fn maybe_instantiate_inline(ccx: @crate_ctxt, fn_id: ast::def_id)
2216
2216
mth. id ] ;
2217
2217
ccx. external . insert ( fn_id, some ( mth. id ) ) ;
2218
2218
compute_ii_method_info ( ccx, impl_did, mth) { |ty, bounds, path|
2219
- let llfn = get_item_val ( ccx, mth. id ) ;
2220
- trans_fn ( ccx, path, mth. decl , mth. body ,
2221
- llfn, impl_self ( ty) , bounds,
2222
- none, mth. id , none) ;
2219
+ if bounds. len ( ) == 0 u {
2220
+ let llfn = get_item_val ( ccx, mth. id ) ;
2221
+ trans_fn ( ccx, path, mth. decl , mth. body ,
2222
+ llfn, impl_self ( ty) , none, mth. id , none) ;
2223
+ }
2223
2224
}
2224
2225
local_def ( mth. id )
2225
2226
}
@@ -4116,7 +4117,6 @@ enum self_arg { impl_self(ty::t), no_self, }
4116
4117
fn trans_closure ( ccx : @crate_ctxt , path : path , decl : ast:: fn_decl ,
4117
4118
body : ast:: blk , llfndecl : ValueRef ,
4118
4119
ty_self : self_arg ,
4119
- tps_bounds : [ ty:: param_bounds ] ,
4120
4120
param_substs : option < param_substs > ,
4121
4121
id : ast:: node_id , maybe_self_id : option < @ast:: expr > ,
4122
4122
maybe_load_env : fn ( fn_ctxt ) ) {
@@ -4125,7 +4125,7 @@ fn trans_closure(ccx: @crate_ctxt, path: path, decl: ast::fn_decl,
4125
4125
// Set up arguments to the function.
4126
4126
let fcx = new_fn_ctxt_w_id ( ccx, path, llfndecl, id, maybe_self_id,
4127
4127
param_substs, some ( body. span ) ) ;
4128
- create_llargs_for_fn_args ( fcx, ty_self, decl. inputs , tps_bounds ) ;
4128
+ create_llargs_for_fn_args ( fcx, ty_self, decl. inputs , [ ] ) ;
4129
4129
4130
4130
// Create the first basic block in the function and keep a handle on it to
4131
4131
// pass to finish_fn later.
@@ -4168,15 +4168,14 @@ fn trans_fn(ccx: @crate_ctxt,
4168
4168
body : ast:: blk ,
4169
4169
llfndecl : ValueRef ,
4170
4170
ty_self : self_arg ,
4171
- tps_bounds : [ ty:: param_bounds ] ,
4172
4171
param_substs : option < param_substs > ,
4173
4172
id : ast:: node_id ,
4174
4173
maybe_self_id : option < @ast:: expr > ) {
4175
4174
let do_time = ccx. sess . opts . stats ;
4176
4175
let start = if do_time { time:: get_time ( ) }
4177
4176
else { { sec: 0u32 , usec: 0u32 } } ;
4178
4177
trans_closure ( ccx, path, decl, body, llfndecl, ty_self,
4179
- tps_bounds , param_substs, id, maybe_self_id, { |fcx|
4178
+ param_substs, id, maybe_self_id, { |fcx|
4180
4179
if ccx. sess . opts . extra_debuginfo {
4181
4180
debuginfo:: create_function ( fcx) ;
4182
4181
}
@@ -4188,12 +4187,12 @@ fn trans_fn(ccx: @crate_ctxt,
4188
4187
}
4189
4188
4190
4189
fn trans_res_ctor ( ccx : @crate_ctxt , path : path , dtor : ast:: fn_decl ,
4191
- ctor_id : ast:: node_id , tps_bounds : [ ty :: param_bounds ] ,
4190
+ ctor_id : ast:: node_id ,
4192
4191
param_substs : option < param_substs > , llfndecl : ValueRef ) {
4193
4192
// Create a function for the constructor
4194
4193
let fcx = new_fn_ctxt_w_id ( ccx, path, llfndecl, ctor_id,
4195
4194
none, param_substs, none) ;
4196
- create_llargs_for_fn_args ( fcx, no_self, dtor. inputs , tps_bounds ) ;
4195
+ create_llargs_for_fn_args ( fcx, no_self, dtor. inputs , [ ] ) ;
4197
4196
let bcx = top_scope_block ( fcx, none) , lltop = bcx. llbb ;
4198
4197
let fty = node_id_type ( bcx, ctor_id) ;
4199
4198
let arg_t = ty:: ty_fn_args ( fty) [ 0 ] . ty ;
@@ -4223,7 +4222,6 @@ fn trans_res_ctor(ccx: @crate_ctxt, path: path, dtor: ast::fn_decl,
4223
4222
4224
4223
fn trans_enum_variant ( ccx : @crate_ctxt , enum_id : ast:: node_id ,
4225
4224
variant : ast:: variant , disr : int , is_degen : bool ,
4226
- ty_params : [ ast:: ty_param ] ,
4227
4225
param_substs : option < param_substs > ,
4228
4226
llfndecl : ValueRef ) {
4229
4227
// Translate variant arguments to function arguments.
@@ -4236,17 +4234,10 @@ fn trans_enum_variant(ccx: @crate_ctxt, enum_id: ast::node_id,
4236
4234
}
4237
4235
let fcx = new_fn_ctxt_w_id ( ccx, [ ] , llfndecl, variant. node . id , none,
4238
4236
param_substs, none) ;
4239
- create_llargs_for_fn_args ( fcx, no_self, fn_args,
4240
- param_bounds ( ccx, ty_params) ) ;
4237
+ create_llargs_for_fn_args ( fcx, no_self, fn_args, [ ] ) ;
4241
4238
let ty_param_substs = alt param_substs {
4242
4239
some( substs) { substs. tys }
4243
- none {
4244
- let i = 0 u;
4245
- vec:: map ( ty_params, { |tp|
4246
- i += 1 u;
4247
- ty:: mk_param ( ccx. tcx , i - 1 u, local_def ( tp. id ) )
4248
- } )
4249
- }
4240
+ none { [ ] }
4250
4241
} ;
4251
4242
let bcx = top_scope_block ( fcx, none) , lltop = bcx. llbb ;
4252
4243
let arg_tys = ty:: ty_fn_args ( node_id_type ( bcx, variant. node . id ) ) ;
@@ -4400,44 +4391,46 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
4400
4391
} ;
4401
4392
alt item. node {
4402
4393
ast:: item_fn ( decl, tps, body) {
4403
- let llfndecl = get_item_val ( ccx, item. id ) ;
4404
- if decl. purity != ast:: crust_fn {
4405
- trans_fn ( ccx, * path + [ path_name ( item. ident ) ] , decl, body,
4406
- llfndecl, no_self, param_bounds ( ccx, tps) ,
4407
- none, item. id , none) ;
4408
- } else {
4394
+ if decl. purity == ast:: crust_fn {
4395
+ let llfndecl = get_item_val ( ccx, item. id ) ;
4409
4396
native:: trans_crust_fn ( ccx, * path + [ path_name ( item. ident ) ] ,
4410
4397
decl, body, llfndecl, item. id ) ;
4398
+ } else if tps. len ( ) == 0 u {
4399
+ let llfndecl = get_item_val ( ccx, item. id ) ;
4400
+ trans_fn ( ccx, * path + [ path_name ( item. ident ) ] , decl, body,
4401
+ llfndecl, no_self, none, item. id , none) ;
4411
4402
}
4412
4403
}
4413
4404
ast:: item_impl ( tps, _, _, ms) {
4414
4405
impl :: trans_impl ( ccx , * path , item . ident, ms , tps ) ;
4415
4406
}
4416
4407
ast:: item_res ( decl, tps, body, dtor_id, ctor_id) {
4417
- let llctor_decl = get_item_val ( ccx , ctor_id ) ;
4418
- trans_res_ctor ( ccx, * path , decl , ctor_id,
4419
- param_bounds ( ccx, tps ) , none, llctor_decl) ;
4408
+ if tps . len ( ) == 0 u {
4409
+ let llctor_decl = get_item_val ( ccx, ctor_id) ;
4410
+ trans_res_ctor ( ccx, * path , decl , ctor_id , none, llctor_decl) ;
4420
4411
4421
- // Create a function for the destructor
4422
- let lldtor_decl = get_item_val ( ccx, item. id ) ;
4423
- trans_fn ( ccx, * path + [ path_name ( item. ident ) ] , decl, body,
4424
- lldtor_decl, no_self, param_bounds ( ccx, tps) ,
4425
- none, dtor_id, none) ;
4412
+ let lldtor_decl = get_item_val ( ccx, item. id ) ;
4413
+ trans_fn ( ccx, * path + [ path_name ( item. ident ) ] , decl, body,
4414
+ lldtor_decl, no_self, none, dtor_id, none) ;
4415
+ }
4426
4416
}
4427
4417
ast:: item_mod ( m) {
4428
4418
trans_mod ( ccx, m) ;
4429
4419
}
4430
4420
ast:: item_enum ( variants, tps) {
4431
- let degen = variants. len ( ) == 1 u;
4432
- let vi = ty:: enum_variants ( ccx. tcx , local_def ( item. id ) ) ;
4433
- let i = 0 ;
4434
- for variant: ast:: variant in variants {
4435
- if variant. node . args . len ( ) > 0 u {
4436
- trans_enum_variant ( ccx, item. id , variant,
4437
- vi[ i] . disr_val , degen, tps,
4438
- none, get_item_val ( ccx, variant. node . id ) ) ;
4421
+ if tps. len ( ) == 0 u {
4422
+ let degen = variants. len ( ) == 1 u;
4423
+ let vi = ty:: enum_variants ( ccx. tcx , local_def ( item. id ) ) ;
4424
+ let i = 0 ;
4425
+ for variant: ast:: variant in variants {
4426
+ let llfn = get_item_val ( ccx, variant. node . id ) ;
4427
+ if variant. node . args . len ( ) > 0 u {
4428
+ trans_enum_variant ( ccx, item. id , variant,
4429
+ vi[ i] . disr_val , degen,
4430
+ none, llfn) ;
4431
+ }
4432
+ i += 1 ;
4439
4433
}
4440
- i += 1 ;
4441
4434
}
4442
4435
}
4443
4436
ast:: item_const ( _, expr) { trans_const ( ccx, expr, item. id ) ; }
@@ -4516,8 +4509,7 @@ fn trans_item(ccx: @crate_ctxt, item: ast::item) {
4516
4509
with ctor. node . body } ;
4517
4510
trans_fn ( ccx, * path + [ path_name ( item. ident ) ] , ctor. node . dec ,
4518
4511
ctor_body__, llctor_decl, no_self,
4519
- param_bounds ( ccx, tps) , none, ctor. node . id ,
4520
- some ( rslt_expr) ) ;
4512
+ none, ctor. node . id , some ( rslt_expr) ) ;
4521
4513
// TODO: translate methods!
4522
4514
}
4523
4515
_ { /* fall through */ }
0 commit comments