@@ -31,17 +31,57 @@ fn run(srv: astsrv::srv, doc: doc::cratedoc) -> doc::cratedoc {
31
31
merge_reexports ( doc, path_map)
32
32
}
33
33
34
+ // Hash maps are not sendable so converting them back and forth
35
+ // to association lists. Yuck.
36
+ fn to_assoc_list < K : copy , V : copy > (
37
+ map : map:: hashmap < K , V >
38
+ ) -> [ ( K , V ) ] {
39
+
40
+ let vec = [ ] ;
41
+ map. items { |k, v|
42
+ vec += [ ( k, v) ] ;
43
+ }
44
+ ret vec;
45
+ }
46
+
47
+ fn from_assoc_list < K : copy , V : copy > (
48
+ list : [ ( K , V ) ] ,
49
+ new_hash : fn ( ) -> map:: hashmap < K , V >
50
+ ) -> map:: hashmap < K , V > {
51
+
52
+ let map = new_hash ( ) ;
53
+ vec:: iter ( list) { |elt|
54
+ let ( k, v) = elt;
55
+ map. insert ( k, v) ;
56
+ }
57
+ ret map;
58
+ }
59
+
60
+ fn from_def_assoc_list < V : copy > (
61
+ list : [ ( ast:: def_id , V ) ]
62
+ ) -> map:: hashmap < ast:: def_id , V > {
63
+ from_assoc_list ( list, bind common:: new_def_hash ( ) )
64
+ }
65
+
66
+ fn from_str_assoc_list < V : copy > (
67
+ list : [ ( str , V ) ]
68
+ ) -> map:: hashmap < str , V > {
69
+ from_assoc_list ( list, bind map:: new_str_hash ( ) )
70
+ }
71
+
34
72
fn build_reexport_def_set ( srv : astsrv:: srv ) -> def_set {
35
- astsrv:: exec ( srv) { |ctxt|
73
+ let assoc_list = astsrv:: exec ( srv) { |ctxt|
36
74
let def_set = common:: new_def_hash ( ) ;
37
75
ctxt. exp_map . items { |_path, defs|
38
76
for def in * defs {
39
77
let def_id = ast_util:: def_id_of_def ( def) ;
40
78
def_set. insert ( def_id, ( ) ) ;
41
79
}
42
80
}
43
- def_set
44
- }
81
+ to_assoc_list ( def_set)
82
+ } ;
83
+
84
+ from_def_assoc_list ( assoc_list)
45
85
}
46
86
47
87
fn build_reexport_def_map (
@@ -85,38 +125,15 @@ fn build_reexport_def_map(
85
125
}
86
126
}
87
127
88
- fn to_assoc_list < V : copy > (
89
- map : map:: hashmap < ast:: def_id , V >
90
- ) -> [ ( ast:: def_id , V ) ] {
91
-
92
- let vec = [ ] ;
93
- map. items { |k, v|
94
- vec += [ ( k, v) ] ;
95
- }
96
- ret vec;
97
- }
98
-
99
- fn from_assoc_list < V : copy > (
100
- list : [ ( ast:: def_id , V ) ]
101
- ) -> map:: hashmap < ast:: def_id , V > {
102
-
103
- let map = common:: new_def_hash ( ) ;
104
- vec:: iter ( list) { |elt|
105
- let ( k, v) = elt;
106
- map. insert ( k, v) ;
107
- }
108
- ret map;
109
- }
110
-
111
128
fn build_reexport_path_map ( srv : astsrv:: srv , -def_map : def_map ) -> path_map {
112
129
113
130
// This is real unfortunate. Lots of copying going on here
114
131
let def_assoc_list = to_assoc_list ( def_map) ;
115
132
#debug ( "def_map: %?" , def_assoc_list) ;
116
133
117
- astsrv:: exec ( srv) { |ctxt|
134
+ let assoc_list = astsrv:: exec ( srv) { |ctxt|
118
135
119
- let def_map = from_assoc_list ( def_assoc_list) ;
136
+ let def_map = from_def_assoc_list ( def_assoc_list) ;
120
137
let path_map = map:: new_str_hash ( ) ;
121
138
122
139
ctxt. exp_map . items { |path, defs|
@@ -149,8 +166,10 @@ fn build_reexport_path_map(srv: astsrv::srv, -def_map: def_map) -> path_map {
149
166
}
150
167
}
151
168
152
- path_map
153
- }
169
+ to_assoc_list ( path_map)
170
+ } ;
171
+
172
+ from_str_assoc_list ( assoc_list)
154
173
}
155
174
156
175
fn merge_reexports (
0 commit comments