Skip to content

Commit

Permalink
auto merge of rust-lang#11030 : cmr/rust/rustdoc_on_fire, r=metajack
Browse files Browse the repository at this point in the history
By returning the items to process and storing them in a queue, we were losing
the context that was setup for that item during the recursion. This is an easy
fix, rather than hoisting out the state that it needs.
  • Loading branch information
bors committed Dec 17, 2013
2 parents d5798b3 + 8b5a317 commit b870ce7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/librustdoc/html/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -648,9 +648,13 @@ impl Context {
self.root_path.push_str("../");
self.current.push(s);

info!("Recursing into {}", self.dst.display());

mkdir(&self.dst);
let ret = f(self);

info!("Recursed; leaving {}", self.dst.display());

// Go back to where we were at
self.dst = prev;
let len = self.root_path.len();
Expand All @@ -674,23 +678,18 @@ impl Context {
// using a rwarc makes this parallelizable in the future
local_data::set(cache_key, Arc::new(cache));

let mut work = ~[item];
while work.len() > 0 {
let item = work.pop();
self.item(item, |_cx, item| {
work.push(item);
})
}
self.item(item);
}

/// Non-parellelized version of rendering an item. This will take the input
/// item, render its contents, and then invoke the specified closure with
/// all sub-items which need to be rendered.
///
/// The rendering driver uses this closure to queue up more work.
fn item(&mut self, item: clean::Item, f: |&mut Context, clean::Item|) {
fn item(&mut self, item: clean::Item) {
fn render(w: io::File, cx: &mut Context, it: &clean::Item,
pushname: bool) {
info!("Rendering an item to {}", w.path().display());
// A little unfortunate that this is done like this, but it sure
// does make formatting *a lot* nicer.
local_data::set(current_location_key, cx.current.clone());
Expand Down Expand Up @@ -734,7 +733,7 @@ impl Context {
};
this.sidebar = build_sidebar(&m);
for item in m.items.move_iter() {
f(this, item);
this.item(item);
}
})
}
Expand Down

0 comments on commit b870ce7

Please sign in to comment.