@@ -84,9 +84,6 @@ type MethodInfo = {
84
84
} ;
85
85
86
86
type Impl = { did : def_id , ident: ident, methods : ~[ @MethodInfo ] } ;
87
- type ImplScope = @~[ @Impl ] ;
88
- type ImplScopes = @list < ImplScope > ;
89
- type ImplMap = hashmap < node_id , ImplScopes > ;
90
87
91
88
// Trait method resolution
92
89
type TraitMap = @hashmap < node_id , @DVec < def_id > > ;
@@ -452,9 +449,6 @@ struct Module {
452
449
// The index of the import we're resolving.
453
450
let mut resolved_import_count: uint ;
454
451
455
- // The list of implementation scopes, rooted from this module.
456
- let mut impl_scopes: ImplScopes ;
457
-
458
452
new( parent_link: ParentLink , def_id: option<def_id>) {
459
453
self . parent_link = parent_link;
460
454
self . def_id = def_id;
@@ -469,8 +463,6 @@ struct Module {
469
463
self . import_resolutions = atom_hashmap ( ) ;
470
464
self . glob_count = 0 u;
471
465
self . resolved_import_count = 0 u;
472
-
473
- self . impl_scopes = @nil;
474
466
}
475
467
476
468
fn all_imports_resolved ( ) -> bool {
@@ -708,7 +700,6 @@ struct Resolver {
708
700
let namespaces: ~[ Namespace ] ;
709
701
710
702
let def_map: DefMap ;
711
- let impl_map: ImplMap ;
712
703
let export_map: ExportMap ;
713
704
let export_map2: ExportMap2 ;
714
705
let trait_map: TraitMap ;
@@ -749,7 +740,6 @@ struct Resolver {
749
740
self . namespaces = ~[ ModuleNS , TypeNS , ValueNS , ImplNS ] ;
750
741
751
742
self . def_map = int_hash( ) ;
752
- self . impl_map = int_hash( ) ;
753
743
self . export_map = int_hash( ) ;
754
744
self . export_map2 = int_hash( ) ;
755
745
self . trait_map = @int_hash( ) ;
@@ -766,9 +756,6 @@ struct Resolver {
766
756
self . record_exports( ) ;
767
757
self . session. abort_if_errors( ) ;
768
758
769
- self . build_impl_scopes( ) ;
770
- self . session. abort_if_errors( ) ;
771
-
772
759
self . resolve_crate( ) ;
773
760
self . session. abort_if_errors( ) ;
774
761
@@ -2809,106 +2796,6 @@ struct Resolver {
2809
2796
}
2810
2797
}
2811
2798
2812
- // Implementation scope creation
2813
- //
2814
- // This is a fairly simple pass that simply gathers up all the typeclass
2815
- // implementations in scope and threads a series of singly-linked series
2816
- // of impls through the tree.
2817
-
2818
- fn build_impl_scopes( ) {
2819
- let root_module = ( * self . graph_root) . get_module( ) ;
2820
- self . build_impl_scopes_for_module_subtree( root_module) ;
2821
- }
2822
-
2823
- fn build_impl_scopes_for_module_subtree( module_: @Module ) {
2824
- // If this isn't a local crate, then bail out. We don't need to
2825
- // resolve implementations for external crates.
2826
-
2827
- match module_. def_id {
2828
- some( def_id) if def_id. crate == local_crate => {
2829
- // OK. Continue.
2830
- }
2831
- none => {
2832
- // Resolve implementation scopes for the root module.
2833
- }
2834
- some( _) => {
2835
- // Bail out.
2836
- debug!{ "( building impl scopes for module subtree) not \
2837
- resolving implementations for `%s`",
2838
- self . module_to_str( module_) } ;
2839
- return ;
2840
- }
2841
- }
2842
-
2843
- self . build_impl_scope_for_module( module_) ;
2844
-
2845
- for module_. children. each |_atom, child_name_bindings| {
2846
- match ( * child_name_bindings) . get_module_if_available( ) {
2847
- none => {
2848
- // Nothing to do.
2849
- }
2850
- some( child_module) => {
2851
- self . build_impl_scopes_for_module_subtree( child_module) ;
2852
- }
2853
- }
2854
- }
2855
-
2856
- for module_. anonymous_children. each |_node_id, child_module| {
2857
- self . build_impl_scopes_for_module_subtree( child_module) ;
2858
- }
2859
- }
2860
-
2861
- fn build_impl_scope_for_module( module_: @Module ) {
2862
- let mut impl_scope = ~[ ] ;
2863
-
2864
- debug!{ "( building impl scope for module) processing module %s ( %?) ",
2865
- self . module_to_str( module_) ,
2866
- copy module_. def_id} ;
2867
-
2868
- // Gather up all direct children implementations in the module.
2869
- for module_. children. each |_impl_name, child_name_bindings| {
2870
- if child_name_bindings. impl_defs. len( ) >= 1 u {
2871
- impl_scope += child_name_bindings. impl_defs;
2872
- }
2873
- }
2874
-
2875
- debug!{ "( building impl scope for module) found %u impl ( s) as direct \
2876
- children",
2877
- impl_scope. len( ) } ;
2878
-
2879
- // Gather up all imports.
2880
- for module_. import_resolutions. each |_impl_name, import_resolution| {
2881
- for ( * import_resolution. impl_target) . each |impl_target| {
2882
- debug!{ "( building impl scope for module) found impl def"} ;
2883
- impl_scope += impl_target. bindings. impl_defs;
2884
- }
2885
- }
2886
-
2887
- debug!{ "( building impl scope for module) found %u impl ( s) in total",
2888
- impl_scope. len( ) } ;
2889
-
2890
- // Determine the parent's implementation scope.
2891
- let mut parent_impl_scopes;
2892
- match module_. parent_link {
2893
- NoParentLink => {
2894
- parent_impl_scopes = @nil;
2895
- }
2896
- ModuleParentLink ( parent_module_node, _) |
2897
- BlockParentLink ( parent_module_node, _) => {
2898
- parent_impl_scopes = parent_module_node. impl_scopes;
2899
- }
2900
- }
2901
-
2902
- // Create the new implementation scope, if it was nonempty, and chain
2903
- // it up to the parent.
2904
-
2905
- if impl_scope. len( ) >= 1 u {
2906
- module_. impl_scopes = @cons( @impl_scope, parent_impl_scopes) ;
2907
- } else {
2908
- module_. impl_scopes = parent_impl_scopes;
2909
- }
2910
- }
2911
-
2912
2799
// AST resolution
2913
2800
//
2914
2801
// We maintain a list of value ribs and type ribs.
@@ -3095,11 +2982,6 @@ struct Resolver {
3095
2982
fn resolve_crate( ) unsafe {
3096
2983
debug!{ "( resolving crate ) starting"} ;
3097
2984
3098
- // To avoid a failure in metadata encoding later, we have to add the
3099
- // crate-level implementation scopes
3100
-
3101
- self . impl_map. insert( 0 , ( * self . graph_root) . get_module( ) . impl_scopes) ;
3102
-
3103
2985
// XXX: This is awful!
3104
2986
let this = ptr:: addr_of( self ) ;
3105
2987
visit_crate( * self . crate , ( ) , mk_vt( @{
@@ -3669,8 +3551,6 @@ struct Resolver {
3669
3551
3670
3552
// Write the implementations in scope into the module metadata.
3671
3553
debug!{ "( resolving module) resolving module ID %d", id} ;
3672
- self . impl_map. insert( id, self . current_module. impl_scopes) ;
3673
-
3674
3554
visit_mod( module_, span, id, ( ) , visitor) ;
3675
3555
}
3676
3556
@@ -4385,13 +4265,8 @@ struct Resolver {
4385
4265
}
4386
4266
4387
4267
fn resolve_expr( expr: @expr, visitor: ResolveVisitor ) {
4388
- // First, write the implementations in scope into a table if the
4389
- // expression might need them.
4390
-
4391
- self . record_impls_for_expr_if_necessary( expr) ;
4392
-
4393
- // Then record candidate traits for this expression if it could result
4394
- // in the invocation of a method call.
4268
+ // First, record candidate traits for this expression if it could
4269
+ // result in the invocation of a method call.
4395
4270
4396
4271
self . record_candidate_traits_for_expr_if_necessary( expr) ;
4397
4272
@@ -4506,19 +4381,6 @@ struct Resolver {
4506
4381
}
4507
4382
}
4508
4383
4509
- fn record_impls_for_expr_if_necessary( expr: @expr) {
4510
- match expr. node {
4511
- expr_field( * ) | expr_path( * ) | expr_cast( * ) | expr_binary( * ) |
4512
- expr_unary( * ) | expr_assign_op( * ) | expr_index( * ) => {
4513
- self . impl_map. insert( expr. id,
4514
- self . current_module. impl_scopes) ;
4515
- }
4516
- _ => {
4517
- // Nothing to do.
4518
- }
4519
- }
4520
- }
4521
-
4522
4384
fn record_candidate_traits_for_expr_if_necessary( expr: @expr) {
4523
4385
match expr. node {
4524
4386
expr_field( _, ident, _) => {
@@ -4855,38 +4717,13 @@ struct Resolver {
4855
4717
module_repr, value_repr, type_repr, impl_repr} ;
4856
4718
}
4857
4719
}
4858
-
4859
- fn dump_impl_scopes( impl_scopes: ImplScopes ) {
4860
- debug!{ "Dump of impl scopes: "} ;
4861
-
4862
- let mut i = 0 u;
4863
- let mut impl_scopes = impl_scopes;
4864
- loop {
4865
- match * impl_scopes {
4866
- cons( impl_scope, rest_impl_scopes) => {
4867
- debug!{ "Impl scope %u: ", i} ;
4868
-
4869
- for ( * impl_scope) . each |implementation| {
4870
- debug!{ "Impl : %s", * implementation. ident} ;
4871
- }
4872
-
4873
- i += 1 u;
4874
- impl_scopes = rest_impl_scopes;
4875
- }
4876
- nil => {
4877
- break ;
4878
- }
4879
- }
4880
- }
4881
- }
4882
4720
}
4883
4721
4884
4722
/// Entry point to crate resolution.
4885
4723
fn resolve_crate( session: session, lang_items: LanguageItems , crate : @crate )
4886
4724
-> { def_map: DefMap ,
4887
4725
exp_map: ExportMap ,
4888
4726
exp_map2: ExportMap2 ,
4889
- impl_map: ImplMap ,
4890
4727
trait_map: TraitMap } {
4891
4728
4892
4729
let resolver = @Resolver ( session, lang_items, crate ) ;
@@ -4895,7 +4732,6 @@ fn resolve_crate(session: session, lang_items: LanguageItems, crate: @crate)
4895
4732
def_map: resolver. def_map,
4896
4733
exp_map: resolver. export_map,
4897
4734
exp_map2: resolver. export_map2,
4898
- impl_map: resolver. impl_map,
4899
4735
trait_map: resolver. trait_map
4900
4736
} ;
4901
4737
}
0 commit comments