Skip to content

Commit 2e67187

Browse files
committed
---
yaml --- r: 147927 b: refs/heads/try2 c: acdc998 h: refs/heads/master i: 147925: 5390efe 147923: 9389a17 147919: c1f3ec0 v: v3
1 parent e421f91 commit 2e67187

File tree

2 files changed

+26
-13
lines changed

2 files changed

+26
-13
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 4269f85d5bc67390af75c28311b17c0032a55c5e
8+
refs/heads/try2: acdc9987371092422dedf88bc8a0542e688986c5
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libsyntax/ast_map.rs

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -197,13 +197,13 @@ pub type map = @RefCell<HashMap<NodeId, ast_node>>;
197197

198198
pub struct Ctx {
199199
map: map,
200-
path: path,
200+
path: RefCell<path>,
201201
diag: @SpanHandler,
202202
}
203203

204204
impl Ctx {
205205
fn extend(&self, elt: path_elt) -> @path {
206-
@vec::append(self.path.clone(), [elt])
206+
@vec::append(self.path.get(), [elt])
207207
}
208208

209209
fn map_method(&mut self,
@@ -275,12 +275,18 @@ impl Ctx {
275275
map.get().insert(a.id, node_arg(a.pat));
276276
}
277277
match *fk {
278-
visit::fk_method(name, _, _) => { self.path.push(path_name(name)) }
278+
visit::fk_method(name, _, _) => {
279+
let mut path = self.path.borrow_mut();
280+
path.get().push(path_name(name))
281+
}
279282
_ => {}
280283
}
281284
visit::walk_fn(self, fk, decl, body, sp, id, ());
282285
match *fk {
283-
visit::fk_method(..) => { self.path.pop(); }
286+
visit::fk_method(..) => {
287+
let mut path = self.path.borrow_mut();
288+
path.get().pop();
289+
}
284290
_ => {}
285291
}
286292
}
@@ -320,7 +326,7 @@ impl Ctx {
320326
impl Visitor<()> for Ctx {
321327
fn visit_item(&mut self, i: @item, _: ()) {
322328
// clone is FIXME #2543
323-
let item_path = @self.path.clone();
329+
let item_path = @self.path.get();
324330
{
325331
let mut map = self.map.borrow_mut();
326332
map.get().insert(i.id, node_item(i, item_path));
@@ -338,7 +344,8 @@ impl Visitor<()> for Ctx {
338344
self.map_method(impl_did, extended, *m, false)
339345
}
340346

341-
self.path.push(elt);
347+
let mut path = self.path.borrow_mut();
348+
path.get().push(elt);
342349
}
343350
item_enum(ref enum_definition, _) => {
344351
for &v in enum_definition.variants.iter() {
@@ -366,7 +373,7 @@ impl Visitor<()> for Ctx {
366373
// Anonymous extern
367374
// mods go in the
368375
// parent scope.
369-
@self.path.clone()
376+
@self.path.get()
370377
));
371378
}
372379
}
@@ -401,13 +408,19 @@ impl Visitor<()> for Ctx {
401408

402409
match i.node {
403410
item_mod(_) | item_foreign_mod(_) => {
404-
self.path.push(path_mod(i.ident));
411+
let mut path = self.path.borrow_mut();
412+
path.get().push(path_mod(i.ident));
405413
}
406414
item_impl(..) => {} // this was guessed above.
407-
_ => self.path.push(path_name(i.ident))
415+
_ => {
416+
let mut path = self.path.borrow_mut();
417+
path.get().push(path_name(i.ident))
418+
}
408419
}
409420
visit::walk_item(self, i, ());
410-
self.path.pop();
421+
422+
let mut path = self.path.borrow_mut();
423+
path.get().pop();
411424
}
412425

413426
fn visit_pat(&mut self, pat: &Pat, _: ()) {
@@ -445,7 +458,7 @@ impl Visitor<()> for Ctx {
445458
pub fn map_crate(diag: @SpanHandler, c: &Crate) -> map {
446459
let cx = @mut Ctx {
447460
map: @RefCell::new(HashMap::new()),
448-
path: ~[],
461+
path: RefCell::new(~[]),
449462
diag: diag,
450463
};
451464
visit::walk_crate(cx, c, ());
@@ -464,7 +477,7 @@ pub fn map_decoded_item(diag: @SpanHandler,
464477
// starting from 0.
465478
let cx = @mut Ctx {
466479
map: map,
467-
path: path.clone(),
480+
path: RefCell::new(path.clone()),
468481
diag: diag,
469482
};
470483

0 commit comments

Comments
 (0)