@@ -144,8 +144,7 @@ pub mod method;
144
144
pub struct SelfInfo {
145
145
self_ty : ty:: t ,
146
146
self_id : ast:: node_id ,
147
- def_id : ast:: def_id ,
148
- explicit_self : ast:: self_ty
147
+ span : span
149
148
}
150
149
151
150
/// Fields that are part of a `FnCtxt` which are inherited by
@@ -339,25 +338,6 @@ pub fn check_fn(ccx: @mut CrateCtxt,
339
338
}
340
339
} ;
341
340
342
- // Update the SelfInfo to contain an accurate self type (taking
343
- // into account explicit self).
344
- let self_info = do self_info. chain_ref |self_info| {
345
- // If the self type is sty_static, we don't have a self ty.
346
- if self_info. explicit_self . node == ast:: sty_static {
347
- None
348
- } else {
349
- let in_scope_regions = fcx. in_scope_regions ;
350
- let self_region = in_scope_regions. find ( ty:: br_self) ;
351
- let ty = method:: transform_self_type_for_method (
352
- fcx. tcx ( ) ,
353
- self_region,
354
- self_info. self_ty ,
355
- self_info. explicit_self . node ,
356
- TransformTypeNormally ) ;
357
- Some ( SelfInfo { self_ty : ty, .. * self_info } )
358
- }
359
- } ;
360
-
361
341
gather_locals ( fcx, decl, body, arg_tys, self_info) ;
362
342
check_block ( fcx, body) ;
363
343
@@ -495,20 +475,25 @@ pub fn check_fn(ccx: @mut CrateCtxt,
495
475
496
476
pub fn check_method ( ccx : @mut CrateCtxt ,
497
477
method : @ast:: method ,
498
- self_ty : ty:: t ,
499
- self_impl_def_id : ast:: def_id ) {
500
- let self_info = SelfInfo {
501
- self_ty : self_ty,
502
- self_id : method. self_id ,
503
- def_id : self_impl_def_id,
504
- explicit_self : method. self_ty
478
+ self_ty : ty:: t )
479
+ {
480
+ let self_info = if method. self_ty . node == ast:: sty_static { None } else {
481
+ let ty = method:: transform_self_type_for_method (
482
+ ccx. tcx ,
483
+ Some ( ty:: re_bound ( ty:: br_self) ) ,
484
+ self_ty,
485
+ method. self_ty . node ,
486
+ TransformTypeNormally ) ;
487
+ Some ( SelfInfo { self_ty : ty, self_id : method. self_id ,
488
+ span : method. self_ty . span } )
505
489
} ;
490
+
506
491
check_bare_fn (
507
492
ccx,
508
493
& method. decl ,
509
494
& method. body ,
510
495
method. id ,
511
- Some ( self_info)
496
+ self_info
512
497
) ;
513
498
}
514
499
@@ -545,11 +530,7 @@ pub fn check_struct(ccx: @mut CrateCtxt,
545
530
let class_t = SelfInfo {
546
531
self_ty : self_ty,
547
532
self_id : dtor. node . self_id ,
548
- def_id : local_def ( id) ,
549
- explicit_self : spanned {
550
- node : ast:: sty_by_ref,
551
- span : codemap:: dummy_sp ( )
552
- }
533
+ span : dtor. span ,
553
534
} ;
554
535
// typecheck the dtor
555
536
let dtor_dec = ast_util:: dtor_dec ( ) ;
@@ -589,7 +570,7 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) {
589
570
* ccx. tcx. sess. str_of( it. ident) , it. id, rp) ;
590
571
let self_ty = ccx. to_ty ( & rscope:: type_rscope ( rp) , ty) ;
591
572
for ms. each |m| {
592
- check_method ( ccx, * m, self_ty, local_def ( it . id ) ) ;
573
+ check_method ( ccx, * m, self_ty) ;
593
574
}
594
575
}
595
576
ast:: item_trait( _, _, ref trait_methods) => {
@@ -601,7 +582,7 @@ pub fn check_item(ccx: @mut CrateCtxt, it: @ast::item) {
601
582
}
602
583
provided( m) => {
603
584
let self_ty = ty:: mk_self ( ccx. tcx , local_def ( it. id ) ) ;
604
- check_method ( ccx, m, self_ty, local_def ( it . id ) ) ;
585
+ check_method ( ccx, m, self_ty) ;
605
586
}
606
587
}
607
588
}
0 commit comments