@@ -5408,8 +5408,7 @@ impl Resolver {
5408
5408
}
5409
5409
}
5410
5410
5411
- fn search_for_traits_containing_method ( & mut self , name : Ident )
5412
- -> ~[ DefId ] {
5411
+ fn search_for_traits_containing_method ( & mut self , name : Ident ) -> ~[ DefId ] {
5413
5412
debug ! ( "(searching for traits containing method) looking for '{}'" ,
5414
5413
self . session. str_of( name) ) ;
5415
5414
@@ -5438,71 +5437,41 @@ impl Resolver {
5438
5437
self . populate_module_if_necessary ( search_module) ;
5439
5438
5440
5439
let children = search_module. children . borrow ( ) ;
5441
- for ( _, & child_name_bindings) in children. get ( ) . iter ( ) {
5442
- match child_name_bindings. def_for_namespace ( TypeNS ) {
5443
- Some ( def) => {
5444
- match def {
5445
- DefTrait ( trait_def_id) => {
5446
- if candidate_traits. contains ( & trait_def_id) {
5447
- self . add_trait_info (
5448
- & mut found_traits,
5449
- trait_def_id, name) ;
5450
- }
5451
- }
5452
- _ => {
5453
- // Continue.
5454
- }
5455
- }
5456
- }
5457
- None => {
5458
- // Continue.
5459
- }
5440
+ for ( _, & child_names) in children. get ( ) . iter ( ) {
5441
+ let def = match child_names. def_for_namespace ( TypeNS ) {
5442
+ Some ( def) => def,
5443
+ None => continue
5444
+ } ;
5445
+ let trait_def_id = match def {
5446
+ DefTrait ( trait_def_id) => trait_def_id,
5447
+ _ => continue ,
5448
+ } ;
5449
+ if candidate_traits. contains ( & trait_def_id) {
5450
+ self . add_trait_info ( & mut found_traits, trait_def_id,
5451
+ name) ;
5460
5452
}
5461
5453
}
5462
5454
5463
5455
// Look for imports.
5464
5456
let import_resolutions = search_module. import_resolutions
5465
5457
. borrow ( ) ;
5466
- for ( _, & import_resolution) in import_resolutions. get ( )
5467
- . iter ( ) {
5468
- match import_resolution. target_for_namespace ( TypeNS ) {
5469
- None => {
5470
- // Continue.
5471
- }
5472
- Some ( target) => {
5473
- match target. bindings . def_for_namespace ( TypeNS ) {
5474
- Some ( def) => {
5475
- match def {
5476
- DefTrait ( trait_def_id) => {
5477
- if candidate_traits. contains ( & trait_def_id) {
5478
- self . add_trait_info (
5479
- & mut found_traits,
5480
- trait_def_id, name) ;
5481
- self . used_imports . insert (
5482
- import_resolution. type_id
5483
- . get ( ) ) ;
5484
- }
5485
- }
5486
- _ => {
5487
- // Continue.
5488
- }
5489
- }
5490
- }
5491
- None => {
5492
- // Continue.
5493
- }
5494
- }
5495
- }
5458
+ for ( _, & import) in import_resolutions. get ( ) . iter ( ) {
5459
+ let target = match import. target_for_namespace ( TypeNS ) {
5460
+ None => continue ,
5461
+ Some ( target) => target,
5462
+ } ;
5463
+ let did = match target. bindings . def_for_namespace ( TypeNS ) {
5464
+ Some ( DefTrait ( trait_def_id) ) => trait_def_id,
5465
+ Some ( ..) | None => continue ,
5466
+ } ;
5467
+ if candidate_traits. contains ( & did) {
5468
+ self . add_trait_info ( & mut found_traits, did, name) ;
5469
+ self . used_imports . insert ( import. type_id . get ( ) ) ;
5496
5470
}
5497
5471
}
5498
5472
5499
- // Move to the next parent.
5500
5473
match search_module. parent_link {
5501
- NoParentLink => {
5502
- // Done.
5503
- break ;
5504
- }
5505
- ModuleParentLink ( parent_module, _) |
5474
+ NoParentLink | ModuleParentLink ( ..) => break ,
5506
5475
BlockParentLink ( parent_module, _) => {
5507
5476
search_module = parent_module;
5508
5477
}
0 commit comments