@@ -88,11 +88,11 @@ struct ReachableContext {
88
88
reachable_symbols : @RefCell < HashSet < ast:: NodeId > > ,
89
89
// A worklist of item IDs. Each item ID in this worklist will be inlined
90
90
// and will be scanned for further references.
91
- worklist : @mut ~[ ast:: NodeId ] ,
91
+ worklist : @RefCell < ~[ ast:: NodeId ] > ,
92
92
}
93
93
94
94
struct MarkSymbolVisitor {
95
- worklist : @mut ~[ ast:: NodeId ] ,
95
+ worklist : @RefCell < ~[ ast:: NodeId ] > ,
96
96
method_map : typeck:: method_map ,
97
97
tcx : ty:: ctxt ,
98
98
reachable_symbols : @RefCell < HashSet < ast:: NodeId > > ,
@@ -116,15 +116,19 @@ impl Visitor<()> for MarkSymbolVisitor {
116
116
if is_local ( def_id) {
117
117
if ReachableContext ::
118
118
def_id_represents_local_inlined_item ( self . tcx , def_id) {
119
- self . worklist . push ( def_id. node )
119
+ {
120
+ let mut worklist = self . worklist . borrow_mut ( ) ;
121
+ worklist. get ( ) . push ( def_id. node )
122
+ }
120
123
} else {
121
124
match def {
122
125
// If this path leads to a static, then we may have
123
126
// to do some work to figure out whether the static
124
127
// is indeed reachable (address_insignificant
125
128
// statics are *never* reachable).
126
129
ast:: DefStatic ( ..) => {
127
- self . worklist . push ( def_id. node ) ;
130
+ let mut worklist = self . worklist . borrow_mut ( ) ;
131
+ worklist. get ( ) . push ( def_id. node ) ;
128
132
}
129
133
130
134
// If this wasn't a static, then this destination is
@@ -150,7 +154,11 @@ impl Visitor<()> for MarkSymbolVisitor {
150
154
def_id_represents_local_inlined_item (
151
155
self . tcx ,
152
156
def_id) {
153
- self . worklist . push ( def_id. node )
157
+ {
158
+ let mut worklist = self . worklist
159
+ . borrow_mut ( ) ;
160
+ worklist. get ( ) . push ( def_id. node )
161
+ }
154
162
}
155
163
{
156
164
let mut reachable_symbols =
@@ -186,7 +194,7 @@ impl ReachableContext {
186
194
tcx : tcx,
187
195
method_map : method_map,
188
196
reachable_symbols : @RefCell :: new ( HashSet :: new ( ) ) ,
189
- worklist : @mut ~[ ] ,
197
+ worklist : @RefCell :: new ( ~[ ] ) ,
190
198
}
191
199
}
192
200
@@ -265,11 +273,19 @@ impl ReachableContext {
265
273
fn propagate ( & self ) {
266
274
let mut visitor = self . init_visitor ( ) ;
267
275
let mut scanned = HashSet :: new ( ) ;
268
- while self . worklist . len ( ) > 0 {
269
- let search_item = self . worklist . pop ( ) ;
270
- if scanned. contains ( & search_item) {
271
- continue
272
- }
276
+ loop {
277
+ let search_item = {
278
+ let mut worklist = self . worklist . borrow_mut ( ) ;
279
+ if worklist. get ( ) . len ( ) == 0 {
280
+ break
281
+ }
282
+ let search_item = worklist. get ( ) . pop ( ) ;
283
+ if scanned. contains ( & search_item) {
284
+ continue
285
+ }
286
+ search_item
287
+ } ;
288
+
273
289
scanned. insert ( search_item) ;
274
290
match self . tcx . items . find ( & search_item) {
275
291
Some ( item) => self . propagate_node ( item, search_item,
@@ -407,7 +423,8 @@ pub fn find_reachable(tcx: ty::ctxt,
407
423
// Step 1: Seed the worklist with all nodes which were found to be public as
408
424
// a result of the privacy pass
409
425
for & id in exported_items. iter ( ) {
410
- reachable_context. worklist . push ( id) ;
426
+ let mut worklist = reachable_context. worklist . borrow_mut ( ) ;
427
+ worklist. get ( ) . push ( id) ;
411
428
}
412
429
413
430
// Step 2: Mark all symbols that the symbols on the worklist touch.
0 commit comments